Re: Low level use of thresholder (Was: Headless ImageJ2-rc2 - Analyze Particles returns no result)
Posted by
dscho on
Jun 13, 2014; 5:55pm
URL: http://imagej.273.s1.nabble.com/Headless-ImageJ2-rc2-Analyze-Particles-returns-no-result-tp5008127p5008209.html
Hi Jan,
On Fri, 13 Jun 2014, Jan Eglinger wrote:
> I just noticed the comment in your example code:
>
> On 13.06.2014, 1:24 PM, Paul van Schayck wrote:
> > IJ.run(imp, "Convert to Mask", ""); // How to use ij.plugin.Thresholder?
>
>
> and wanted to share how I have done it [*1*]:
>
> import ij.WindowManager;
> import ij.plugin.Thresholder;
>
> [...]
>
> private Thresholder thr;
>
> [...]
>
> WindowManager.setTempCurrentImage(imp);
> thr.run("mask");
> WindowManager.setTempCurrentImage(null);
>
> If anyone has a more elegant solution, I would be happy to hear it.
You could also make use of the static methods in
fiji.threshold.Auto_Threshold (i.e. Gabriel Landini's Auto Threshold
plugin) with the histogram obtained via
http://jenkins.imagej.net/job/ImageJ1-javadoc/javadoc/ij/process/ImageProcessor.html#getHistogram%28%29then set the threshold via
http://jenkins.imagej.net/job/ImageJ1-javadoc/javadoc/ij/process/ImageProcessor.html#setThreshold%28double,%20double,%20int%29and if you need a mask, turn the threshold into a ROI via
http://jenkins.imagej.net/job/ImageJ1-javadoc/javadoc/ij/plugin/filter/ThresholdToSelection.html#run%28ij.ImagePlus%29and then make the mask by calling
http://jenkins.imagej.net/job/ImageJ1-javadoc/javadoc/ij/process/ImageProcessor.html#setRoi%28ij.gui.Roi%29and
http://jenkins.imagej.net/job/ImageJ1-javadoc/javadoc/ij/process/ImageProcessor.html#getMask%28%29I know, not very straight-forward... but thread-safe! Well, kinda...
Ciao,
Johannes
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html