ParticleAnalyzer instance inside/outside loop

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ParticleAnalyzer instance inside/outside loop

gankaku
Hi all,

Trying to put the "Speckle Inspector" from macro status into a plugin I
came across a behaviour which I (in my small java world) could not explain
myself. Potentially, someone can enlighten me. When I create a new
ParticleAnalyzer first, then start a loop wherein ROIs are applied on an
image and then the ParticleAnalyzer is used to analyze these ROIs, I always
ended up with only the result of the first ROI, repetitively (see code
snippet 1).

Code snippet 1

...........some code ..............
ParticleAnalyzer analyzeSpeckles = new ParticleAnalyzer(analyzerOptions,
measurementFlags, rt, minSpeckleSize, maxSpeckleSize);

for(int o=0; o<objectNumber; o++) {

imp2.setRoi(roi[o], true);

analyzeSpeckles.analyze(imp2, ip2);
specklesPerObject[o] = rt.getCounter();
rt.reset();
analyzeSpeckles = null;

}

...........more code ..............



If I create a new ParticleAnalyzer every time the loop goes into a new
round (code snippet 2) the problem is solved.


Code snippet 2

...........some code ..............
for(int o=0; o<objectNumber; o++) {

ParticleAnalyzer analyzeSpeckles = new ParticleAnalyzer(analyzerOptions,
measurementFlags, rt, minSpeckleSize, maxSpeckleSize);

imp2.setRoi(roi[o], true);

analyzeSpeckles.analyze(imp2, ip2);


.........more code..........

}

...........even more code ..............

So, besides the fact that there is actually no problem, I was wondering why
I need to create for each new ROI analysis a new ParticleAnalyzer?
This (even potentially little) will occupy much more memory and if I
analyze many ROIs it might also affect the performance (correct me if I am
wrong).

I thought that the ParticleAnalyzer object just creates the "toolbox" and
defines how an image and in this case a ROI inside an image is analyzed by
the pa.analyze(imp) method. Since I specify the ImagePlus I want to run
this method on directly when I call the method it should recognize that in
each run there is a new ROI and give the results of that one (which it
doesn't). This is my actual problem in understanding this behaviour and I
am looking forward to an explanation.

--------------------------------------------------------------------
Besides this: I uploaded a bugfixed version of the "Advanced Particle
Analyzer" as part of the BioVoxxel Toolbox since (thanks to Sidnei
Paciornik) we figured out that the elimination of some particles in scaled
images did not work properly. So, please check your results again if you
used scaled images so far.
This is fixed in the latest version (
http://sites.imagej.net/BioVoxxel/macros/toolsets/BioVoxxel_Toolbox.ijm-20140707143854).
For Fiji users simply update from the BioVoxxel update site.
Furthermore, the "Pixel units" checkbox applies now to the "Area",
"Perimeter" and "Max. Feret" parameters in scaled images. For any
inconsistency please contact me to check and fix it if necessary!

Soon (after a few more tests), also the Speckle Inspector will be provided
as recordable plugin to increase applicability in macros. Binary Feature
Extractor and Watershed Irregular Features will follow as well.

cheers,
Jan

--

CEO: Dr. rer. nat. Jan Brocher
phone:  +49 (0)6234 917 03 39
mobile: +49 (0)176 705 746 81
e-mail: [hidden email]
info: [hidden email]
inquiries: [hidden email]
web: www.biovoxxel.de

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html