Hi Miguel,
first, make sure that you put the curly braces into the right place.
ImageJ is not python; it's the braces, not the indent that determine the
program flow.
Second, it does not help to set a variable like 'count', 'name' if you
do nothing with it.
I guess that you want something like the following:
newImage("Untitled", "8-bit black", 400, 400, 1);
run("32-bit");
nBins = 256;
histMin = 0;
histMax = 256;
run("Clear Results");
getHistogram(values, counts, nBins, histMin, histMax);
for (j=0; j<nBins; j++) {
if (counts[j] == 0)
counts[j] = NaN;
setResult("Bin", j, values[j]);
setResult("Numbers", j, counts[j]);
}
updateResults();
name = getTitle();
name = name + ".csv";
IJ.renameResults(name);
Michael
________________________________________________________________
On 2016-11-16 20:58, Miguel Tapia R. wrote:
> Hello everyone,
>
> I would like to exchange "0" values I obtained from a 32-bit image to
> "NaN" in the Results window. I wrote the following macro:
>
>
> newImage("Untitled", "8-bit black", 400, 400, 1);
>
> run("32-bit");
>
> nBins = 256; histMin = 0; histMax = 256;
>
> run("Clear Results"); row=0;
>
> getHistogram(values, counts, nBins, histMin, histMax);
>
> for (j=0; j<nBins; j++) { setResult("Bin", row, values[j]);
> setResult("Numbers", row, counts[j]); count = counts[j]; if
> (count==0) count=NaN; updateResults(); row++;
>
> name = getTitle; name = name + ".csv";
>
> }
>
> in the Results window, bin 0 has all the values (in this case 160000)
> and the rest of bins shows "0" and i would ask if it is possible to
> change 0 to NaN to be displayed.
>
> Thanks in advance,
>
>
> Miguel
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html