Login  Register

Re: Triangle ROI values

Posted by Wayne Rasband on Apr 10, 2007; 11:01pm
URL: http://imagej.273.s1.nabble.com/Triangle-ROI-values-tp3699794p3699795.html

Get the mask and use it to decide if the pixel is inside or outside the
ROI. There is an example at

     http://rsbweb.nih.gov/ij/plugins/calculate-mean.html

-wayne


On Apr 10, 2007, at 4:57 PM, Nilesh Powar wrote:

> Hello All,
>
>   I am using  a triangle roi & I needed to know all the points  inside
> the roi. Suppose there are 50pixels inside the roi, i need to  know
> the location of everypixel (x,y) & also need to know the value  of the
> pixel.
>
>   I know if  it is rectangular roi, you can get the height & width of
> the rectangle & traverse through the roi.
>
>   Rectangle r=ip.getRoi();
>   for (int y=r.y; y<(r.y+r.height); y++)
>    {
>       offset = y*width;
>       for (int x=r.x; x<(r.x+r.width); x++)
>       {
>             X1[k1]=x;
>            Y1[k1]=y;
>            Z1[k1]=ip.getPixelValue(x,y);
>            k1=k1+1;
>       }
>   }
>
>   However, how will you do if it is a triangle ROI???
>
>   Thanks,
>   Nilesh...
>
>