plugin - thresholding a 32-bit image

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

plugin - thresholding a 32-bit image

Ben Tupper
Hello,

IJ version 1.41k

I am perplexed by the behavior of the setThreshold method for a  
FloatProcessor class.  I have a 32-bit image that  I would like to  
threshold to values of "threshLaplace" and greater.  In my code  
snippet below I have created a duplicate of the original 32-bit  
image. When I show the thresholded image (mhMaskIp) I expect to see  
the red/black arrangement I see when I use the menu commands.  But I  
don't.  Instead I see a copy of the original.


     //create the MH mask
     //this shows where the MH is GE threshLaplace
     mhMaskImp = new ImagePlus("MH-Mask",mhIp.duplicate());
     mhMaskIp = mhMaskImp.getProcessor();
     mhMaskIp.setThreshold( (double) threshLaplace, 1000000.0,  
FloatProcessor.RED_LUT);
     mhMaskImp.show();

Ultimately, I would like to have the original and the masked images  
(as byte is OK) without having to show them.

Thanks and cheers,
Ben
Reply | Threaded
Open this post in threaded view
|

Re: plugin - thresholding a 32-bit image

Ben Tupper
Hi All,

Wayne provided a solution that I want to post for the archive.  Note  
the time Wayne responded! It is always a good time for ImageJ. Thanks  
Wayne!

Cheers,
Ben


On Sep 17, 2008, at 12:36 AM, Rasband Wayne wrote:

> On Sep 17, 2008, at 12:30 AM, Rasband Wayne wrote:
>
>> Hello,
>>
>> IJ version 1.41k
>>
>> I am perplexed by the behavior of the setThreshold method for a
>> FloatProcessor class.  I have a 32-bit image that  I would like to
>> threshold to values of "threshLaplace" and greater.  In my code
>> snippet below I have created a duplicate of the original 32-bit
>> image. When I show the thresholded image (mhMaskIp) I expect to see
>> the red/black arrangement I see when I use the menu commands.  But I
>> don't.  Instead I see a copy of the original.
>>
>>
>>      //create the MH mask
>>      //this shows where the MH is GE threshLaplace
>>      mhMaskImp = new ImagePlus("MH-Mask",mhIp.duplicate());
>>      mhMaskIp = mhMaskImp.getProcessor();
>>      mhMaskIp.setThreshold( (double) threshLaplace, 1000000.0,
>> FloatProcessor.RED_LUT);
>>      mhMaskImp.show();
>>
>> Ultimately, I would like to have the original and the masked images
>> (as byte is OK) without having to show them.
>
> Ben,
>
> It might help to reset the display range of the image using  
> resetMinAndMax(). This Javascript example works as expected.
>
>      IJ.newImage("Bulls Eye", "32-bit Ramp", 512, 512, 1);
>      mhIp = IJ.getImage().getProcessor();
>      mhIp.multiply(1000000.0);
>      mhMaskImp = new ImagePlus("MH-Mask",mhIp.duplicate());
>      mhMaskIp = mhMaskImp.getProcessor();
>      mhMaskIp.resetMinAndMax();
>      mhMaskIp.setThreshold( 500000, 1000000, FloatProcessor.RED_LUT);
>      mhMaskImp.show();
>
> -wayne