Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jul 08, 2015; 3:39am
URL: http://imagej.273.s1.nabble.com/How-to-get-the-bin-start-values-tp5013454p5013463.html
> On Jul 7, 2015, at 8:41 AM, Avital Steinberg <
[hidden email]> wrote:
>
> Hi,
> When I select a ROI and choose analyze, histogram, I get a histogram for
> the selection. I am doing this for a 16 bit image. Below the histogram, I
> see the values Min and Max. (among other values)
>
> In a macro, I can use:
>
> roiManager("Select", 0);
> getHistogram(0, counts, 256);
>
> To select a ROI and get the histogram. How would I find the Min and Max
> values that are listed below the histogram in a macro? How are these values
> calculated?
>
> In other words: how can I get the x-values for the histogram and not just
> the counts?
The getHistogram() macro function returns the x-values in the first argument. The following macro displays a histogram plot based on the values returned by getHistogram() and getRawStatistics().
-wayne
run("M51 Galaxy (177K, 16-bits)");
bins = 256;
getHistogram(values, counts, bins);
getRawStatistics(count, mean, min, max, std);
binWidth = (max-min)/bins;
Plot.create("Histogram", "Value", "Count", values, counts);
Plot.addText("Count: "+count, 0.3, 0.2);
Plot.addText("Mean: "+mean, 0.3, 0.3);
Plot.addText("StdDev: "+std, 0.3, 0.4);
Plot.addText("Bins: "+bins, 0.3, 0.5);
Plot.addText("Min: "+min, 0.3, 0.6);
Plot.addText("Max: "+max, 0.3, 0.7);
Plot.addText("Bin Width: "+ binWidth, 0.3, 0.8);
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html