Hi ImageJ developers,
I am trying to get some measures ( as specified and set measurements) on an color image however on its specific area defined by another mask images. I am trying to do that by java codes..actually, i try to do this in image J by doing particle analyzer on my mask image then adding this to ROI manger and then do measures in ROI manger when set measure are redirected to my main image. I have written a piece of code but the counter below returns me 0..I am new to imageJ so I appreciate any help so I can write this program.. This is the piece of my code but i don't get any result ========== File f = new File(Test.class.getResource("/IMD002.bmp").toURI()); File f1 = new File(Test.class.getResource("/IMD002_R1_Label4.bmp").toURI()); ColorProcessor image = new ColorProcessor(ImageIO.read(f)); //ByteProcessor mask = new ByteProcessor(ImageIO.read(f1)); ColorProcessor maskI=new ColorProcessor(ImageIO.read(f1)); ImagePlus imP=new ImagePlus("tt",maskI); IJ.run(imP,"8-bit", "");//conveting the mask ti 8 bit image ResultsTable rt=new ResultsTable(); ParticleAnalyzer pt=new ParticleAnalyzer (ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET, ij.measure.Measurements.AREA+ij.measure.Measurements.MEAN, rt, 1, 1000, 1, 1000); ImagePlus img=new ImagePlus(); img.setProcessor(image); RoiManager roi=RoiManager.getInstance(); pt.setRoiManager(roi); ij.plugin.filter.Analyzer.setRedirectImage(img); pt.analyze(imP); ResultsTable rt1 = ij.plugin.filter.Analyzer.getResultsTable(); int counter = rt1.getCounter(); //number of results System.out.println(counter); //if (counter==0) //no results, handle that error here int col = rt1.getColumnIndex("Area"); for (int row=0; row<counter; row++) { double value = rt1.getValueAsDouble(col, row); System.out.println(value); } ====== Thanks any one if has any tip? Regards |
Hi lukyluke,
it seems there are two bugs in your code: (1) your call the ParticleAnalyzer with minCirc=1, maxCirc=1000 You will never find a particle with a circularity greater than 1. (2) If you tell the ParticleAnalyzer to use the ResultsTable rt, you can't expect the results in ResultsTable rt1. Michael ________________________________________________________________ On Nov 19, 2014, at 10:48, luckyluke wrote: > Hi ImageJ developers, > > I am trying to get some measures ( as specified and set measurements) on an > color image however on its specific area defined by another mask images. > > I am trying to do that by java codes..actually, i try to do this in image J > by doing particle analyzer on my mask image then adding this to ROI manger > and then do measures in ROI manger when set measure are redirected to my > main image. > > I have written a piece of code but the counter below returns me 0..I am new > to imageJ so I appreciate any help so I can write this program.. > > > This is the piece of my code but i don't get any result > > ========== > File f = new File(Test.class.getResource("/IMD002.bmp").toURI()); > File f1 = new > File(Test.class.getResource("/IMD002_R1_Label4.bmp").toURI()); > ColorProcessor image = new ColorProcessor(ImageIO.read(f)); > //ByteProcessor mask = new ByteProcessor(ImageIO.read(f1)); > ColorProcessor maskI=new ColorProcessor(ImageIO.read(f1)); > ImagePlus imP=new ImagePlus("tt",maskI); > IJ.run(imP,"8-bit", "");//conveting the mask ti 8 bit image > ResultsTable rt=new ResultsTable(); > > ParticleAnalyzer pt=new ParticleAnalyzer > (ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET, > ij.measure.Measurements.AREA+ij.measure.Measurements.MEAN, > rt, 1, 1000, 1, 1000); > > > ImagePlus img=new ImagePlus(); > img.setProcessor(image); > RoiManager roi=RoiManager.getInstance(); > pt.setRoiManager(roi); > ij.plugin.filter.Analyzer.setRedirectImage(img); > pt.analyze(imP); > ResultsTable rt1 = ij.plugin.filter.Analyzer.getResultsTable(); > int counter = rt1.getCounter(); //number of results > System.out.println(counter); > //if (counter==0) > //no results, handle that error here > int col = rt1.getColumnIndex("Area"); > for (int row=0; row<counter; row++) > { > double value = rt1.getValueAsDouble(col, row); > System.out.println(value); > } > > ====== > > > Thanks any one if has any tip? > > Regards > > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Getting-measures-from-some-ares-in-an-image-by-a-mask-tp5010537.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |