Re: Iterator over Roi points anywhere?
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/Iterator-over-Roi-points-anywhere-tp5016087p5016115.html
On Apr 12, 2016, at 2:17 AM, Dimitri Vanhecke <
[hidden email]> wrote:
>
> Hi,
> Great question. Is there any chance there is an equally nice solution on macro writing level? Currently I use a (time consuming) workaround by making all pixels outside the ROI black and subtracting 1 from all pixels in the image. Then I iterate through the bounding box of the ROI and use an if statement to check if the value of the pixel. If -1, then we must be outside the ROI...
> A nice solution like the getcontainedpoints method would be great (and much faster, I assume).
The latest ImageJ daily build (1.51a9) adds the Roi.getContainedPoints() macro function. Here is an example macro that uses this function to calculate the mean pixel value of the current selection:
sum=0; count=0;
Roi.getContainedPoints(x,y);
for (i=0; i<x.length; i++) {
count++;
sum += getPixel(x[i], y[i]);
}
print("mean,count: "+d2s(sum/count,4)+" "+count);
-wayne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html