reading values from a histogram within ImageJ

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

reading values from a histogram within ImageJ

Jeremy Adler
1) How can I read the values in a histogram within ImageJ
I can export the values but I want to perform a calculation within imageJ.
Presumably the data in the histogram exists somewhere as a 256,1 32 bit array.

2) When thresholding it would be helpful to be able to see the log version of the histogram, to identify how well the threshold fits minor peaks. The log version is available from analyse/histogram.



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Rasband, Wayne (NIH/NIMH) [E]
Sent: den 13 maj 2014 19:45
To: [hidden email]
Subject: Re: Export grayscale values from a stack into text or excel file

On May 13, 2014, at 11:35 AM, fm017 wrote:

> Dear All,
>
> I have an Image Sequence (about 100 slices) as 8bit in ImageJ. Now I
> would like to export the grayscale values (like with
> ANALYZE/HISTOGRAM/LIST) for every slice into a text or Excel file.
> All values in one file.  I mean a table with one column for grayscale
> values followed by many columns (for each slice one column) with the
> (pixel-) counts.
> I would be glad for any suggestions, plugins, macros or something.

Here is a macro that saves histogram counts of all images in a stack as a comma separated text file:

  run("Clear Results");
  setOption("ShowRowNumbers", false);
  for (slice=1; slice<=nSlices; slice++) {
     setSlice(slice);
     getRawStatistics(n, mean, min, max, std, hist);
     for (i=0; i<hist.length; i++) {
        setResult("Value", i, i);
        setResult("Count"+slice, i, hist[i]);
     }
  }
  path = getDirectory("home")+"histogram-counts.csv";
  saveAs("Results", path);

> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Export-grayscale-values-from-a-stack-
> into-text-or-excel-file-tp5007716.html
> Sent from the ImageJ mailing list archive at Nabble.com.

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

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

Re: reading values from a histogram within ImageJ

Michael Entrup
Dear Jeremy,

to answer your first question, I have an URL for you: [1].

Scroll down until you reach 'getHistogram(values, counts, nBins[,
histMin, histMax])'. There are some examples that show how to work with
'getHistogram(...)'.

I can't give you a concrete answer to the second question. As far as I
know, you have to modify the code of the threshold routine. The source
code is available at [2]. If you are familiar with Java, you can create
a new plug-in, that uses a modified version of this code.

Best regards
Michael

[1] http://rsbweb.nih.gov/ij/developer/macro/functions.html#G
[2] http://rsbweb.nih.gov/ij/source/ij/process/AutoThresholder.java


Am 14.05.2014 09:32, schrieb Jeremy Adler:
> 1) How can I read the values in a histogram within ImageJ
> I can export the values but I want to perform a calculation within imageJ.
> Presumably the data in the histogram exists somewhere as a 256,1 32 bit array.
>
> 2) When thresholding it would be helpful to be able to see the log version of the histogram, to identify how well the threshold fits minor peaks. The log version is available from analyse/histogram.

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