Posted by
Michael Schmid on
Apr 29, 2008; 4:25pm
URL: http://imagej.273.s1.nabble.com/list-histogram-values-without-GUI-tp3696342p3696343.html
Hi Federica,
your macro seems to work well - the only difference I see is
the numbering of the rows:
ImageJ starts numbering the rows in the "Results" window with 1,
not 0, so everything is shifted by one.
To avoid this, you could add a column for the value:
getHistogram(values, counts, 256);
for (row=0; row<256; row++) {
setResult("Value", row, row);
setResult("Count", row, counts[row]);
}
updateResults();
When saving and reading the results, ignore the first column.
By the way, when testing the macro one easy way to get fooled
is first running Analyze>Histogram, then running the macro for
comparison. This will create a histogram of the "Histogram"
window, not of the original window. So make sure that the
correct foreground image is selected when running the macro.
Michael
________________________________________________________________
On 29 Apr 2008, at 14:22, federica viti wrote:
> Hi guys,
> you helped me last time and I hope I'll be lucky also this time..
>
> I am working with ImageJ 1.38 without GUI.
> I want to extract data from the histogram of a surface plot.
> I tried with the code suggested on line..something like that (the
> input is
> the saved Surface Plot):
>
> row = 0;
> getHistogram(values, counts, 256);
> for (i=0; i<256; i++) {
> setResult("Count", row, counts[i]);
> row++;
> }
> updateResults();
> selectWindow("Results");
> directory="/my/dir";
> name="myResults";
> txtPath = directory+name+".txt";
> save(txtPath);
>
> It works, but actually the list of values that I obtain is
> different from
> the one that I have in the GUI mode.
> In the latter mode I apply the 'Histogram' function to the Surface
> Plot and
> then I can visualize histogram data clicking on the 'List' option
> on the
> histogram window.
> I'm wondering if I can access to the same list of value, maybe
> running the
> 'List' command in NO GUI mode, so that I can obtain in a
> programmatic way
> (only running my macro) the list of histogram values that I'm
> interested
> into.
>
> Hope I've been clear..
>
> Thank you,
> Federica