Re: Percentile value
Posted by
Michael Schmid on
Sep 29, 2009; 3:02pm
URL: http://imagej.273.s1.nabble.com/Percentile-value-tp3690983p3690989.html
Hi Jan,
Concerning looping over all pixels and sorting them - if you don't
need the pixel coordinates, it would be much faster to use the
histogram. The getRawStatistics macro function uses the pixels inside
the selection and returns also the histogram.
In case you have float (32 bit) images and you need better resolution
than 256 levels, use getHistogram; there you can specify the number
of bins.
Concerning your second question, it might be a nice addition to
ImageJ to have an option for the "Percentile" threshold method, where
one can specify the percentile - currently it is always 50%.
Michael
________________________________________________________________
On 29 Sep 2009, at 16:02, Jan Eglinger wrote:
> Hi all,
>
> following up on the issue of measuring percentiles in ImageJ...
>
> Wayne Rasband wrote:
>>> To get the percentile value, I think that I could get all the pixel
>>> value by using getpixel (I,j) and make an array.
>>> Then I need to sort the array. How do I sort the array using ImageJ
>>> macro language? Do you have to make a function?
>>
>> Use the Array.sort() macro function to sort an array. Here is an
>> example
>> macro that creates an array from all pixels in an image then sorts
>> the
>> array:
>>
>> requires ("1.42j");
>> w = getWidth;
>> h = getHeight;
>> a = newArray(w*h);
>> i = 0;
>> for (y=0; y<h; y++)
>> for (x=0; x<w; x++)
>> a[i++] = getPixel(x,y);
>> Array.sort(a);
>>
>
> Is there an easy way to limit that array to the thresholded pixels
> or to
> an ROI only?
>
> Or is there even a chance to integrate an option "percentile" into the
> "Set Measurements..." dialog, together with a parameter telling which
> percentile (0.01-0.99)?
> That would permit to make use of e.g. the "Redirect" option while
> measuring percentiles.
>
> Best,
> Jan