automatic threshold value

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

automatic threshold value

Paxton Provitera
Hi.
How does the Image>Adjust>Threshold... function determine the value at which
it assigns the threshold limit, and how can I access that value in a plugin?

Thanks for your help.

-Paxton
Reply | Threaded
Open this post in threaded view
|

Re: automatic threshold value

Rotella, Anthony M. (GRC)[]
Paxton,

        I do believe this is discussed in the ImageJ FAQ on the website.
As far accessing it in a plug-in, I am sure you should be able to, but I
don't know how. I am sure someone else will chime in with that.

Regards,

Tony

>-----Original Message-----
>From: ImageJ Interest Group [mailto:[hidden email]] On
>Behalf Of Paxton Provitera
>Sent: Wednesday, August 08, 2007 10:33 AM
>To: [hidden email]
>Subject: automatic threshold value
>
>Hi.
>How does the Image>Adjust>Threshold... function determine the
>value at which it assigns the threshold limit, and how can I
>access that value in a plugin?
>
>Thanks for your help.
>
>-Paxton
>
Reply | Threaded
Open this post in threaded view
|

Re: automatic threshold value

Michael Schmid
In reply to this post by Paxton Provitera
Hi Paxton,

in a plugin you can use
   int thresholdInt = ip.getAutoThreshold(int[] histogram);
with the histogram obtained from ImageStatistics.
You will get which index of the histogram that the threshold
corresponds to - for uncalibrated 8-bit images this is the
threshold; otherwise conversion is necessary - I guess
something like the following:
   double threshold = min + thresholdInt/(double)histogram.length*
(max-min);

You won't get whether the thresholded (red) pixels will be
above or below the threshold.
Strange enough, the code for this decision (and also for
conversion of histogram index to a float value) is not public
in ImageJ and also duplicate (but slightly different) in
Functions.java and ThresholdAdjuster.java


Michael
________________________________________________________________

On 8 Aug 2007, at 16:32, Paxton Provitera wrote:

> Hi.
> How does the Image>Adjust>Threshold... function determine the value  
> at which
> it assigns the threshold limit, and how can I access that value in  
> a plugin?
>
> Thanks for your help.
>
> -Paxton
Reply | Threaded
Open this post in threaded view
|

Re: automatic threshold value

Michael Schmid
Hi,

Sorry, a correction:

It should be

   double threshold =
       min + thresholdInt/(double)(histogram.length-1)*(max-min);

(mind the "minus 1")

For histograms that come from ImageStatistics, the length is
always 256 (irrespective of image type), so the code simplifies
to
     double threshold = min + thresholdInt/255.0*(max-min);

min and max also come from ImageStatistics.


Michael
________________________________________________________________

On 8 Aug 2007, at 17:18, Michael Schmid wrote:

> Hi Paxton,
>
> in a plugin you can use
>   int thresholdInt = ip.getAutoThreshold(int[] histogram);
> with the histogram obtained from ImageStatistics.
> You will get which index of the histogram that the threshold
> corresponds to - for uncalibrated 8-bit images this is the
> threshold; otherwise conversion is necessary - I guess
> something like the following:
>   double threshold = min + thresholdInt/(double)histogram.length*
> (max-min);
>
> You won't get whether the thresholded (red) pixels will be
> above or below the threshold.
> Strange enough, the code for this decision (and also for
> conversion of histogram index to a float value) is not public
> in ImageJ and also duplicate (but slightly different) in
> Functions.java and ThresholdAdjuster.java
>
>
> Michael
> ________________________________________________________________
>
> On 8 Aug 2007, at 16:32, Paxton Provitera wrote:
>
>> Hi.
>> How does the Image>Adjust>Threshold... function determine the  
>> value at which
>> it assigns the threshold limit, and how can I access that value in  
>> a plugin?
>>
>> Thanks for your help.
>>
>> -Paxton
Reply | Threaded
Open this post in threaded view
|

Re: automatic threshold value

lechristophe
In reply to this post by Paxton Provitera
see http://rsb.info.nih.gov/ij/docs/faqs.html

Christophe


Paxton Provitera wrote
Hi.
How does the Image>Adjust>Threshold... function determine the value at which
it assigns the threshold limit, and how can I access that value in a plugin?

Thanks for your help.

-Paxton