The first code simply do a 2D counting using Particle Analyzer after segmenting the image. It works fine and I can see the normal counting as expected,

```
imagePlusfiltered = new Duplicator().run(imagePlus);
IJ.run(imagePlusfiltered, "Make Binary", "method=Default background=Dark calculate");
ParticleAnalyzer particleAnalyzer = new ParticleAnalyzer(
ParticleAnalyzer.INCLUDE_HOLES +
ParticleAnalyzer.STACK_POSITION ,
-1, rt, 5, Double.MAX_VALUE, 0, 1);
for (int imgSliceindx=0 ; imgSliceindx < imagePlusfiltered.getStackSize(); imgSliceindx++) {
imagePlusfiltered.setSliceWithoutUpdate(imgSliceindx+1);
particleAnalyzer.analyze(imagePlusfiltered);
particleAnalyzer.setRoiManager(roi);
particleAnalyzer.setResultsTable(rt);
}
```

- The result
**without**inversion line before 2D counting analyzing line (white background) - The result
**with**inversion line (black background)

In the second case I am doing the same steps just added on it a subtraction step the original from a median filtered one and this time the counting is showing 1 per channel as if the image is inverted. Inverting the image doesn’t solve the problem.

```
ImagePlus imagePlusDuplicate = new Duplicator().run(imagePlus);
// filtering the original image and subtracting the result from the original
IJ.run(imagePlusDuplicate, "Median...", "radius=15 stack");
ImageCalculator imageCalculator = new ImageCalculator();
imagePlusfiltered = imageCalculator.run("Subtract create stack", imagePlus, imagePlusDuplicate);
// applying segmentation and post processing
IJ.run(imagePlusfiltered, "Make Binary", "method=Default background=Dark calculate");
IJ.run(imagePlusfiltered, "Dilate", "stack");
IJ.run(imagePlusfiltered, "Erode", "stack");
// 2D Counting for all slices
ParticleAnalyzer particleAnalyzer = new ParticleAnalyzer(
ParticleAnalyzer.INCLUDE_HOLES +
ParticleAnalyzer.STACK_POSITION ,
-1, rt, 5, Double.MAX_VALUE, 0, 1);
for (int imgSliceindx=0 ; imgSliceindx < imagePlusfiltered.getStackSize(); imgSliceindx++) {
imagePlusfiltered.setSliceWithoutUpdate(imgSliceindx+1);
particleAnalyzer.analyze(imagePlusfiltered);
particleAnalyzer.setRoiManager(roi);
particleAnalyzer.setResultsTable(rt);
}
```

The result same as before

Can anyone guess what would be the problem or what approach I can take to get close to where the problem is.