I know this is not a straight forward question but for the moment I can’t figure out a way to investigate the problem. I created a java code that is applying one filter, converting it to binary and using Particle Analyzer. If there is any difference in count to what I am expecting, I always test using ImageJ Macro. Below, is the macro I run,
open("C:/.../diff result Image.tif"); run("Duplicate...", "duplicate"); run("Median...", "radius=15 stack"); imageCalculator("Subtract create stack", "diff result Image.tif","diff result Image-1.tif"); selectWindow("diff result Image.tif"); close(); selectWindow("diff result Image-1.tif"); close(); selectWindow("Result of diff result Image.tif"); run("Make Binary", "method=Default background=Default calculate black"); run("Analyze Particles...", "size=5-Infinity pixel display clear add stack");
The equivalent code in Java I am running
// Opening CZI images ImporterOptions options = new ImporterOptions(); options.setId(imageFile.getPath()); ImagePlus imps = BF.openImagePlus(options); imp = imps; // Opening Tiff Images imp = IJ.openImage(imageFile.getPath()); // Filtering and Segmenting ImagePlus imagePlusDuplicate = new Duplicator().run(imp); IJ.run(imagePlusDuplicate, "Median...", "radius=15 stack"); ImageCalculator imageCalculator = new ImageCalculator(); ImagePlus imagePlusFiltered = imageCalculator.run("Subtract create stack", imp, imagePlusDuplicate); segmentedImage = new Duplicator().run(imagePlusFiltered ); IJ.run(segmentedImage, "Make Binary", "method=Default background=Dark calculate"); // Using Particle Analyzer rt = new ResultsTable(); ParticleAnalyzer particleAnalyzer = new ParticleAnalyzer( ParticleAnalyzer.INCLUDE_HOLES + ParticleAnalyzer.STACK_POSITION, -1, rt, 5,Double.MAX_VALUE, 0, 1); particleAnalyzer.setResultsTable(rt); // From previous I get the x and y as follows, double xDouble = rt.getColumnAsDoubles(6); double yDouble = rt.getColumnAsDoubles(7); // finally I convert them to integers as inputs to another method to be drawn // I still don't know the decimal values in the double what it is for (int) xDouble[i] (int) yDouble[i]
Currently I have a case that when I opened CZI file and run my Java code, the x and y location of particles is limited to a small square on the top left of the image while in imageJ it is running correctly. Running that same Java code on different images that are not of CZI source, the x and y positions are shown correctly even with different size of images.
I still have problems with the view but seems that the markers are shown correctly with the normal image,
While for the CZI image,
I thought about Calibration to be a reason for the problem, but I am not sure if there is an automatic calibration that is done by ImageJ in the background. Any other probable reasons for this problem for me to investigate would be appreciated.