Rectangular and non-Rectangular Rois

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

Rectangular and non-Rectangular Rois

Mohamed Tleis
Dear Members,

I am trying to work with pixels within a certain Roi; In order to process
the pixels ; I had to get the rectangle bounding the ROI, which is supposed
to be non-rectangular; But trying to count the pixels inside the Roi and
inside the rectangle; It turned out to be the same;
This made me believe that the Rois are actually rectangles!?
But the weird thing is: when I draw these Rois their outlines are not
rectangular; Therefore, I am missing something; Can you please clear it out
? I would appreciate any tutorials about this topic if avaiable.

I used the following code to count roi pixels.
[code]

        Rectangle r_roi = roi.getBounds();

        ip.setRoi(roi);


                for(int i = 0; i<r_roi.width; i++) {
                    for(int j =0; j<roi_height; j++)
                    {
                        if (roi.contains(i, j));
                        {
                            gray_Sum[x][y]+=ip.getPixel(i,j);
                            contained_Count++;
                        }
                        count++;
                    }
                }

               System.out.println(" ROI count : " + count );
               System.out.println(" ROI cotained count : " +
contained_Count );

            }
        }
[/code]
Reply | Threaded
Open this post in threaded view
|

Re: Rectangular and non-Rectangular Rois

Rasband, Wayne (NIH/NIMH) [E]
There is an example plugin at

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

that demonstrates how to work with non-rectangular ROIs.

-wayne

_________________________________
From: Mohammed Tlais [[hidden email]]
Sent: Friday, March 02, 2012 10:02 AM
To: List IMAGEJ
Subject: Rectangular and non-Rectangular Rois

Dear Members,

I am trying to work with pixels within a certain Roi; In order to process
the pixels ; I had to get the rectangle bounding the ROI, which is supposed
to be non-rectangular; But trying to count the pixels inside the Roi and
inside the rectangle; It turned out to be the same;
This made me believe that the Rois are actually rectangles!?
But the weird thing is: when I draw these Rois their outlines are not
rectangular; Therefore, I am missing something; Can you please clear it out
? I would appreciate any tutorials about this topic if avaiable.

I used the following code to count roi pixels.
[code]

        Rectangle r_roi = roi.getBounds();

        ip.setRoi(roi);


                for(int i = 0; i<r_roi.width; i++) {
                    for(int j =0; j<roi_height; j++)
                    {
                        if (roi.contains(i, j));
                        {
                            gray_Sum[x][y]+=ip.getPixel(i,j);
                            contained_Count++;
                        }
                        count++;
                    }
                }

               System.out.println(" ROI count : " + count );
               System.out.println(" ROI cotained count : " +
contained_Count );

            }
        }
[/code]