Thank you - this was perfect. -Kenneth Sloan
On Mon, Aug 19, 2024 at 04:15 Michael Schmid <[email protected]> wrote: > Hi Kenneth, > > as I understand it, your long question boils down to "how to use the > ParticleAnalyzer from a Java plugin". > > For my feeling, probably the best is using the constructor > public ParticleAnalyzer(int options, int measurements, ResultsTable > rt, double minSize, double maxSize, double minCirc, double maxCirc) > > where options and measurements are bitwise or of the flags. > The options flags are those of the ParticleAnalyzer, from > ParticleAnalyzer.SHOW_RESULTS to ParticleAnalyzer.OVERLAY, and the > measurements flags are defined in ij.measure.Measurements (you can > implement this class to have them directly available). > > If you supply a ResultsTable, you can use it later to retrieve the > results. If it is a ResultsTable created in your code, you donÄt need to > show it. > > Use the analyze method of the ParticleAnalyzer created: > public boolean analyze(ImagePlus imp) > > Best have a look at the source code, > > > > https://github.com/imagej/ImageJ/blob/master/ij/plugin/filter/ParticleAnalyzer.java > > > > Michael > ________________________________________________________________ > On 18.08.24 15:03, Kenneth Sloan wrote: > > First - I deal with Java plugins, and have very little experience with > the GUI or macros. I’d like to keep it that way for this project. I’m > trying to build a completely automatic segmentation program, in Java. The > task is relatively simple. > > > > I have a segmentation task involving size and shape - but also location > in the image. I could live with sketching a polygon around an ROI, but > would prefer to instead use distance from the center of the image (and > include only regions which are close to the center of the image). > > > > Experimenting with the GUI, using global thresholding and “Analyze > Particles”, I have gotten to the point where filtering on size and > circularity is giving me good results - with a few stray regions outside > the region I care about. > > > > So…I’m now ready to write Java code to look at the results of “Analyze > Particles” and filter based on location. > > > > One option is to create a mask and then edit the mask, based on either a > manually drawn polygon, or distance from the center of the image. That’s > my current first choice - I can do that without any assistance. > > > > Another option is to loosen the criteria used by “Analyze Particles” and > then do further filtering of a list of regions. This is where I need > help. I have no experience with generating, and then processing, a list of > regions produced by “Analyze Particles”. This looks like a good > opportunity to repair my ignorance. > > > > What API’s should I look at? How do I invoke “Analyze Particles” from > Java, and how do I access the results? > > > > Secondarily, I’m finding that “circularity” does not completely capture > the shapes I’m interested in. I’d appreciate pointers in methods of > analyzing individual segmented regions, specifically to eliminate long, > thin regions. ROI filtering (or distance from the center of the image) > will probably be sufficient - but I’d like to have both belt and suspenders. > > > > Finally, I may be interested in measuring various properties of the > segmented regions, such as perimeter, etc. > > > > Ideally, I’d like to see example Java code that runs “Analyze Particles” > and then processes a list of particles. Macro code would be fine - I can > translate from that. > > > > Probably sufficient is a list of APIs to look at. > > > > All clues gratefully appreciated. > > > > If absolutely necessary, I can provide a few sample images, but I’m > really not authorized to publish these images widely. > > > > -- > > Kenneth Sloan > > [email protected] > > Vision is the art of seeing what is invisible to others. > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
