Modify names and class in composite classifier

Hi everyone, I have a problem that is probably easy to solve, but obviously I can’t solve.
I created a Composite classifier by merging two classifiers
The first divided objects into “thin” and “large” using a Min diameter cutoff.
The second divided objects into “smallarea” and “bigarea” based on an Area cutoff.

I have now got 4 classes:
thin: bigarea
thin: smallarea
large: bigarea
large: smallarea

This is my Detection Map:

This is my Composite Classifier Code:

{
  "object_classifier_type": "CompositeClassifier",
  "classifiers": [
    {
      "object_classifier_type": "SimpleClassifier",
      "function": {
        "classifier_fun": "ClassifyByMeasurementFunction",
        "measurement": "Min diameter µm",
        "pathClassBelow": {
          "name": "thin",
          "colorRGB": -13251169
        },
        "pathClassEquals": {
          "name": "thin",
          "colorRGB": -13251169
        },
        "pathClassAbove": {
          "name": "large",
          "colorRGB": -1969093
        },
        "threshold": 30.0
      },
      "pathClasses": [
        {
          "name": "thin",
          "colorRGB": -13251169
        },
        {
          "name": "large",
          "colorRGB": -1969093
        }
      ],
      "filter": "DETECTIONS_ALL",
      "timestamp": 1602685627748
    },
    {
      "object_classifier_type": "SimpleClassifier",
      "function": {
        "classifier_fun": "ClassifyByMeasurementFunction",
        "measurement": "Area µm^2",
        "pathClassBelow": {
          "name": "smallarea",
          "colorRGB": -9996574
        },
        "pathClassEquals": {
          "name": "bigarea",
          "colorRGB": -65536
        },
        "pathClassAbove": {
          "name": "bigarea",
          "colorRGB": -65536
        },
        "threshold": 800.0
      },
      "pathClasses": [
        {
          "name": "smallarea",
          "colorRGB": -9996574
        },
        {
          "name": "bigarea",
          "colorRGB": -65536
        }
      ],
      "filter": "DETECTIONS_ALL",
      "timestamp": 1602878205781
    }
  ]
}

Now I would like to rename my objects (both class and name) as follows:
thin: bigarea = small
thin: smallarea = small
large: bigarea = big
large: smallarea = small

Can anyone help me change the code? thanks a lot

I wouldn’t bother changing the code, just reclassify.

getDetectionObjects().each{
  if (it.getPathClass() == getPathClass("large: bigarea")){
    it.setPathClass(getPathClass("big"))
  }else{
    it.setPathClass(getPathClass("small"))
  }
}

I have not tested the code and you may need to adjust it to specifically fit your needs.

thanks, it works perfectly. I thought of modifying the classifier to be able to merge it with other classifiers, but in reality I could use this “escamotage” at the end of the whole process to rename every single class.

1 Like