Problem with seMinAndMax

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

Problem with seMinAndMax

Michael Doube
Hi all

I've been struggling with a little macro that will automatically window
some 16-bit CT images of dry bone in air.  I want air to be black and
bone to be shades of grey with nice dynamic range.

If I manually set Window and Level, macro recorder tells me the code is:

setMinAndMax(31468, 32959);

and my image looks how I want it

However, if I run this code from a macro window, my image goes black as
the window level is way too low (the ramp goes off the right of the W&L
graph).

Any ideas what might be going on?

Cheers

Mike

ij 1.39r Java 1.6.0_04 WinXP SP2

--
Dr Michael Doube  BPhil BVSc PhD MRCVS
Research Associate
Department of Bioengineering
Imperial College London
South Kensington Campus
London  SW7 2AZ
United Kingdom
Reply | Threaded
Open this post in threaded view
|

Re: Problem with setMinAndMax

Michael Doube
I have figured it out - setMinAndMax expects 16-bit signed values (
−32768 to 32767) while my images are 16-bit unsigned (0 to 65535). So
subtracting 32768 from min and max values fixes the problem.

Mike

Michael Doube wrote:

> Hi all
>
> I've been struggling with a little macro that will automatically
> window some 16-bit CT images of dry bone in air. I want air to be
> black and bone to be shades of grey with nice dynamic range.
>
> If I manually set Window and Level, macro recorder tells me the code is:
>
> setMinAndMax(31468, 32959);
>
> and my image looks how I want it
>
> However, if I run this code from a macro window, my image goes black
> as the window level is way too low (the ramp goes off the right of the
> W&L graph).
>
> Any ideas what might be going on?
>
> Cheers
>
> Mike
>
> ij 1.39r Java 1.6.0_04 WinXP SP2
>


--
Michael Doube  BPhil BVSc PhD MRCVS
Research Associate
Department of Bioengineering
Imperial College London
South Kensington Campus
London  SW7 2AZ
United Kingdom
Reply | Threaded
Open this post in threaded view
|

Re: Problem with seMinAndMax

Wayne Rasband
In reply to this post by Michael Doube
> I've been struggling with a little macro that will automatically
> window some 16-bit CT images of dry bone in air.  I want air to be
> black and bone to be shades of grey with nice dynamic range.
>
> If I manually set Window and Level, macro recorder tells me the code
> is:
>
> setMinAndMax(31468, 32959);
>
> and my image looks how I want it
>
> However, if I run this code from a macro window, my image goes black
> as the window level is way too low (the ramp goes off the right of the
> W&L graph).
>
> Any ideas what might be going on?

This is a macro recorder bug that is fixed in ImageJ 1.39s, due by the
end of week. It should record

     setMinAndMax(-200, 300)

when you open the "CT" sample image and click "Set" in the B&C window,
but instead it records

     setMinAndMax(32568, 33068);

-wayne