Posted by
Aryeh Weiss on
URL: http://imagej.273.s1.nabble.com/how-to-apply-theshholds-ot-image-tp5019448p5019452.html
Hi Michael
Thanks again for your quick reply.
On 27/09/2017 23:24, Michael Schmid wrote:
> Hi Aryeh,
>
> if you have an 8-bit image you can apply the current threshold with
> imp = IJ.getImage();
> IJ.run(imp, "Convert to Mask", "");
>
I tried this before I posted. What I get is the following command:
IJ.run(imp, "Convert to Mask", "method=Default background=Dark black")
If I leave out the arguments in my script, then the attached pop-up menu
will appear.
If I use:
IJ.run(imp, "Convert to Mask", "background=Dark black")
without the method parameter, it will not pop up the menu, but it will
use one of the methods to auto-threshold (probably the most recent or
default selection). I can see that the binary image produced does not
match theoverlay from the thresholds.
I tried to record Image>Threshold>Apply Threshold, and it threw the
following exception:
java.lang.RuntimeException: java.util.concurrent.ExecutionException:
java.lang.ClassCastException:
net.imagej.ops.commands.threshold.GlobalThresholder cannot be cast to
net.imagej.ops.OpEnvironment
at
net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:291)
at
net.imagej.legacy.DefaultLegacyHooks.interceptRunPlugIn(DefaultLegacyHooks.java:163)
at ij.IJ.runPlugIn(IJ.java)
at ij.Executer.runCommand(Executer.java:137)
at ij.Executer.run(Executer.java:63)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException:
java.lang.ClassCastException:
net.imagej.ops.commands.threshold.GlobalThresholder cannot be cast to
net.imagej.ops.OpEnvironment
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at
net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:287)
... 5 more
Caused by: java.lang.ClassCastException:
net.imagej.ops.commands.threshold.GlobalThresholder cannot be cast to
net.imagej.ops.OpEnvironment
Best regards
--aryeh
> (here it is written the Javascript or Python way)
>
> You can find out with Plugins>Macros>Record; set the Recorder to
> 'JavaScript'.
>
> Michael
> ________________________________________________________________
>
> On 27/09/2017 20:20, Aryeh Weiss wrote:
>> After I run:
>>
>> ip.setThreshold(stats.mean-multiplier*stats.stdDev,
>> 2**imp.getBitDepth(), ImageProcessor.RED_LUT)
>>
>> I have the thresholds associated with the image. I even see the
>> correct overlay.
>> However, I cannot figure how to apply these thresholds to the image
>> in order to create a binary image.
>>
>> IJ.run(imp, "Convert to Mask", " background=Dark black")
>>
>> applies one of the automatic threshholding methods, (even though I
>> removed that option from the argument list).
>>
>> I tried also, ip.setBinaryThreshold(), but it does not appear to do
>> what I want (I am not quite sure what it does)
>>
>> How are thresholds used to create a binary image?
>>
>> Thanks again in advance
>> --aryeh
>>
>
--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel
Ph: 972-3-5317638
FAX: 972-3-7384051
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html