gethistogram() inside selection macro problem

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

gethistogram() inside selection macro problem

Sebastien
Hi,

When calling getHistogram() on an active selection drawn with polyline (or by using the wand) the function returns the pixel count inside the bounding box of the selection, not inside the selection. Oddly if ImageJ histogram is first called from the menu on the same selection then the result of the macro is correct.

This is demonstrated by this simple macro. It should be run a 16-bit image holding, for instance, two overlapping filled rectangles (with different gray values) and an active selection obtained by wand selecting the rectangle in the back.

rename("Image");
print("Call 1");
getHistogram(values, counts, 65536);
for(j=1;j<65536;j++)if(counts[j]>0)print(j);
run("Histogram");
selectImage("Image");
print("Call 2");
getHistogram(values, counts, 65536);
for(j=1;j<65536;j++)if(counts[j]>0)print(j);

Any explanation?

Best,
Sébastien

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

Re: gethistogram() inside selection macro problem

Rasband, Wayne (NIH/NIMH) [E]
On Feb 8, 2013, at 5:48 AM, Sébastien Tosi wrote:

> Hi,
>
> When calling getHistogram() on an active selection drawn with polyline (or by using the wand) the function returns the pixel count inside the bounding box of the selection, not inside the selection. Oddly if ImageJ histogram is first called from the menu on the same selection then the result of the macro is correct.
>
> This is demonstrated by this simple macro. It should be run a 16-bit image holding, for instance, two overlapping filled rectangles (with different gray values) and an active selection obtained by wand selecting the rectangle in the back.
>
> rename("Image");
> print("Call 1");
> getHistogram(values, counts, 65536);
> for(j=1;j<65536;j++)if(counts[j]>0)print(j);
> run("Histogram");
> selectImage("Image");
> print("Call 2");
> getHistogram(values, counts, 65536);
> for(j=1;j<65536;j++)if(counts[j]>0)print(j);
>
> Any explanation?

This odd behavior is due to a bug that is fixed in the ImageJ 1.47j daily build.

-wayne

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