Thresholding and keeping a 16bit image.

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

Thresholding and keeping a 16bit image.

daggaz
This seems simple, yet searching I find no answers..

I have 16bit images.  I would very much like to threshold these, effectively setting any pixels below my threshold limit to zero, while keeping the rest of the data intact.  Setting the correct threshold is simple, but applying the changes not only forces a save into 8bit, it rewrites all the thresholded values as 255.  (I simply cannot understand why this is the default setting, why force a user to wipe data?)

Is there any way around this, or is there some way to use the resulting mask to clip my data (perhaps with the math menus)?

Thanks for the help,
Ian
Reply | Threaded
Open this post in threaded view
|

Re: Thresholding and keeping a 16bit image.

Gabriel Landini
On Wednesday 13 Jun 2012 21:03:48 daggaz wrote:
> I have 16bit images.  I would very much like to threshold these, effectively
> setting any pixels below my threshold limit to zero, while keeping the rest
> of the data intact.  Setting the correct threshold is simple, but applying
> the changes not only forces a save into 8bit, it rewrites all the
> thresholded values as 255.  (I simply cannot understand why this is the
> default setting, why force a user to wipe data?)

The default behaviour is correct, it is just that what you want to do is not
really thresholding .

If you know the values (lets say from 0 to 260) then you can change those by
running a 1 line macro:

changeValues(0, 260, 0);

This will zero all the pixels between 0 and 260.

http://imagej.nih.gov/ij/developer/macro/functions.html#C

Cheers
G.

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

Re: Thresholding and keeping a 16bit image.

daggaz
Is it possible to run this command without using a macro?  I have to change the value constantly.  Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Thresholding and keeping a 16bit image.

Philip Ershler
Create a macro that has a dialog that asks for values you wish to use.

Phil

On Jun 13, 2012, at 3:33 PM, daggaz wrote:

> Is it possible to run this command without using a macro?  I have to change
> the value constantly.  Thanks.
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/Thresholding-and-keeping-a-16bit-image-tp4999045p4999049.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Philip R. Ershler Ph.D.
University of Utah
Cardiovascular Research and Training Institute
95 South 2000 East
Salt Lake City, UT 84112-5000

phone: (801) 230-8771
alt ph: (801) 587-9528
fax: (801) 581-3128
e-mail: [hidden email]



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

Re: Thresholding and keeping a 16bit image.

samjlord
In reply to this post by daggaz
daggaz wrote
(I simply cannot understand why this is the default setting, why force a user to wipe data?)
I have also been confused by this before. The reason is that "threshold" means that anything above the threshold is "on" and anything below is "off," so it makes a binary image.

To do what you're asking, you could follow the previous suggestions. Another option that might work for you is to subtract a value from every pixel, using the Process->Math->Subtract command.

Good luck!
Reply | Threaded
Open this post in threaded view
|

Re: Thresholding and keeping a 16bit image.

Bill Christens-Barry
In reply to this post by daggaz
The way I do this is to make a binary mask filled with values of 0 and 65535. I then AND this with the original. It's pretty easy in the macro language. Example:

    selectWindow("2bThresholded");
    run("Duplicate...", "title=16-bitMask");
    setThreshold(23456, 65535);
    run("Convert to Mask");
    run("16-bit");
    changeValues(255, 65535, 65535);
    setPasteMode("AND");
    run("Select All");
    run("Copy");
    run("Close");
    selectWindow("2bThresholded");
    run("Paste");
    run("Select None");
    rename("HasBeenThresholded");

There are lots of options for how you set the threshold values, both manually and via automation.

hth...

Bill Christens-Barry

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html