Triangle ROI values

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

Triangle ROI values

Nilesh Powar
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...
 
Reply | Threaded
Open this post in threaded view
|

Re: Triangle ROI values

Wayne Rasband
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...
>
>