Problem with Oval ROI

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

Problem with Oval ROI

ganeshjothikumar
Hi all
   
            I have an image over which I have to draw circles with certain center points and certain radius. I am using Oval ROI to dothis in a plugin. The code is something like this
                       
   
                      ImagePlus imp = WindowManager.getCurrentImage();
                    ip = imp.getProcessor();
                      Roi roi = new OvalRoi(10,10,100,100);
                      ip.setColor(new Color(13,14,23));                
                    ip.setMask(roi.getMask());
                    ip.setRoi(roi.getBoundingRect());
                    ip.fill(ip.getMask());
                      imp.updateAndDraw();

   
  Actually the oval gets drawn but not with center 10,10. It is drawn as though teh oval was drawn starting from 10,10 anddragging across. So if I want to draw a circle with center as 10,10 and radius as 100 hw can I do with Oval ROI or is there any other approach. Also I need to fill the circle with some colour. And I ned to detect the circle in the future also.. I should be able to select the circle and drag it.
   
  Please help me in this...
   
  Thanks
  ganesh

       
---------------------------------
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Oval ROI

Justin McGrath
Since x and y are the coordinates of the corner of the bounding
rectangle, the center is at (xc, yc) where
xc = x + width/2
yc = y +height/2

so obviously
x = xc - width/2
y = yc - width/2

so to get a circle with a center at (xc,yc) and radius of r use
OvalRoi(xc-r/2,yc-r/2,r,r)
which in your example is
OvalRoi(10-100/2,10-100/2,100,100)

I don't know much about the plugin API, but I think you can the
RoiManager class to store the circle for later.  Don't know about
filling the circle with a plugin, but if you combine with plugin with
a macro you could use fill()

Justin

On 8/1/07, Ganesh Jothikumar <[hidden email]> wrote:

> Hi all
>
>             I have an image over which I have to draw circles with certain center points and certain radius. I am using Oval ROI to dothis in a plugin. The code is something like this
>
>
>                       ImagePlus imp = WindowManager.getCurrentImage();
>                     ip = imp.getProcessor();
>                       Roi roi = new OvalRoi(10,10,100,100);
>                       ip.setColor(new Color(13,14,23));
>                     ip.setMask(roi.getMask());
>                     ip.setRoi(roi.getBoundingRect());
>                     ip.fill(ip.getMask());
>                       imp.updateAndDraw();
>
>
>   Actually the oval gets drawn but not with center 10,10. It is drawn as though teh oval was drawn starting from 10,10 anddragging across. So if I want to draw a circle with center as 10,10 and radius as 100 hw can I do with Oval ROI or is there any other approach. Also I need to fill the circle with some colour. And I ned to detect the circle in the future also.. I should be able to select the circle and drag it.
>
>   Please help me in this...
>
>   Thanks
>   ganesh
>
>
> ---------------------------------
> Building a website is a piece of cake.
> Yahoo! Small Business gives you all the tools to get online.
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Oval ROI

ganeshjothikumar
Justin....Thank you very much.. That helps a lot...
   
  If anybody can give some more info about storing the circles using Roi Manager or someother means that woud be really helpful. Some code snippt or something ....
   
  Also can somebody help me on a plugin to drag an already existing Oval ROI on an image from the current location to someother location using the mouse..
   
  Thanks in advance
  ganesh

Justin McGrath <[hidden email]> wrote:
  Since x and y are the coordinates of the corner of the bounding
rectangle, the center is at (xc, yc) where
xc = x + width/2
yc = y +height/2

so obviously
x = xc - width/2
y = yc - width/2

so to get a circle with a center at (xc,yc) and radius of r use
OvalRoi(xc-r/2,yc-r/2,r,r)
which in your example is
OvalRoi(10-100/2,10-100/2,100,100)

I don't know much about the plugin API, but I think you can the
RoiManager class to store the circle for later. Don't know about
filling the circle with a plugin, but if you combine with plugin with
a macro you could use fill()

Justin

On 8/1/07, Ganesh Jothikumar wrote:

> Hi all
>
> I have an image over which I have to draw circles with certain center points and certain radius. I am using Oval ROI to dothis in a plugin. The code is something like this
>
>
> ImagePlus imp = WindowManager.getCurrentImage();
> ip = imp.getProcessor();
> Roi roi = new OvalRoi(10,10,100,100);
> ip.setColor(new Color(13,14,23));
> ip.setMask(roi.getMask());
> ip.setRoi(roi.getBoundingRect());
> ip.fill(ip.getMask());
> imp.updateAndDraw();
>
>
> Actually the oval gets drawn but not with center 10,10. It is drawn as though teh oval was drawn starting from 10,10 anddragging across. So if I want to draw a circle with center as 10,10 and radius as 100 hw can I do with Oval ROI or is there any other approach. Also I need to fill the circle with some colour. And I ned to detect the circle in the future also.. I should be able to select the circle and drag it.
>
> Please help me in this...
>
> Thanks
> ganesh
>
>
> ---------------------------------
> Building a website is a piece of cake.
> Yahoo! Small Business gives you all the tools to get online.
>


       
---------------------------------
Yahoo! oneSearch: Finally,  mobile search that gives answers, not web links.