question about ImageProcessor.setThreshold()

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

question about ImageProcessor.setThreshold()

Aryeh Weiss
I have the following python script (using auto-imports for testing)..

def thresholdFromBackground(imp, multiplier = 3):
     ip = imp.getProcessor()
     wd = WaitForUserDialog("Create a background selection")
     wd.show()
     roi = imp.getRoi()
     stats = imp.getStatistics(Measurements.MEAN | Measurements.STD_DEV )
     print stats.mean, stats.stdDev
     print stats.mean-multiplier*stats.stdDev, 2**imp.getBitDepth()
     ip.setThreshold(stats.mean-multiplier*stats.stdDev,
2**imp.getBitDepth(), ImageProcessor.RED_LUT)
     imp.show()


imp = IJ.getImage()
thresholdFromBackground(imp, multiplier = 3)


It runs without error,  and prints out the correct means and stdDev.
However, it does not display the red LUT overlay that I expect  from the
RED_LUT parameter.

If I use the static metho|d|

|IJ.run(imp, "Convert to Mask", "") to test if the thresholds were set,
I  get the expected result.|

|What do I need to do to see the red overlay (other than using the
static IJ.setThreshold)|

|Thanks 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
Reply | Threaded
Open this post in threaded view
|

Re: question about ImageProcessor.setThreshold()

Michael Schmid-3
Hi Aryeh,

to show any changes to an ImagePlus on the screen, you need
   imp.updateAndDraw()
instead of
   imp.show()


Michael
________________________________________________________________
On 27/09/2017 17:43, Aryeh Weiss wrote:

> I have the following python script (using auto-imports for testing)..
>
> def thresholdFromBackground(imp, multiplier = 3):
>      ip = imp.getProcessor()
>      wd = WaitForUserDialog("Create a background selection")
>      wd.show()
>      roi = imp.getRoi()
>      stats = imp.getStatistics(Measurements.MEAN | Measurements.STD_DEV )
>      print stats.mean, stats.stdDev
>      print stats.mean-multiplier*stats.stdDev, 2**imp.getBitDepth()
>      ip.setThreshold(stats.mean-multiplier*stats.stdDev,
> 2**imp.getBitDepth(), ImageProcessor.RED_LUT)
>      imp.show()
>
>
> imp = IJ.getImage()
> thresholdFromBackground(imp, multiplier = 3)
>
>
> It runs without error,  and prints out the correct means and stdDev.
> However, it does not display the red LUT overlay that I expect  from the
> RED_LUT parameter.
>
> If I use the static metho|d|
>
> |IJ.run(imp, "Convert to Mask", "") to test if the thresholds were set,
> I  get the expected result.|
>
> |What do I need to do to see the red overlay (other than using the
> static IJ.setThreshold)|
>
> |Thanks in advance
> --aryeh|
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: question about ImageProcessor.setThreshold()

Aryeh Weiss
Hi Michael

Thank you for your fast response. Works as advertised.

Is the show method only  used when there is not a window already open
for that ImagePlus.

--aryeh

On 27/09/2017 19:03, Michael Schmid wrote:

> Hi Aryeh,
>
> to show any changes to an ImagePlus on the screen, you need
>   imp.updateAndDraw()
> instead of
>   imp.show()
>
>
> Michael
> ________________________________________________________________
> On 27/09/2017 17:43, Aryeh Weiss wrote:
>> I have the following python script (using auto-imports for testing)..
>>
>> def thresholdFromBackground(imp, multiplier = 3):
>>      ip = imp.getProcessor()
>>      wd = WaitForUserDialog("Create a background selection")
>>      wd.show()
>>      roi = imp.getRoi()
>>      stats = imp.getStatistics(Measurements.MEAN |
>> Measurements.STD_DEV )
>>      print stats.mean, stats.stdDev
>>      print stats.mean-multiplier*stats.stdDev, 2**imp.getBitDepth()
>>      ip.setThreshold(stats.mean-multiplier*stats.stdDev,
>> 2**imp.getBitDepth(), ImageProcessor.RED_LUT)
>>      imp.show()
>>
>>
>> imp = IJ.getImage()
>> thresholdFromBackground(imp, multiplier = 3)
>>
>>
>> It runs without error,  and prints out the correct means and stdDev.
>> However, it does not display the red LUT overlay that I expect  from
>> the RED_LUT parameter.
>>
>> If I use the static metho|d|
>>
>> |IJ.run(imp, "Convert to Mask", "") to test if the thresholds were
>> set, I  get the expected result.|
>>
>> |What do I need to do to see the red overlay (other than using the
>> static IJ.setThreshold)|
>>
>> |Thanks in advance
>> --aryeh|
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
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