[Insight-users] Drawing a circle

Matthieu Jomier mat-list at jomier.com
Mon Apr 4 09:25:27 EDT 2005


Ilaria,

You can look at the itkHoughTransform2DCirclesImage test file in:
Insight/Testing/Code/BasicFilters/itkHoughTransform2DCirclesImageTest.cx
x

from line 191.

A simple loop can do what you want:

typedef   unsigned char                            PixelType;
typedef   itk::Image< PixelType, 2>                ImageType;
ImageType::IndexType index;

yourbinaryimage->FillBuffer(0);

double radius = yourradius;
ImageType::IndexType center;
center[0] = yourcenterposX;
center[1] = yourcenterposY;

for(double angle = 0; angle <= 2*PI ; angle += PI/1000)
{
  index[0] = (long int)(center[0] + radius * cos(angle));
  index[1] = (long int)(center[1] + radius * sin(angle));
  yourbinaryimage->SetPixel(index,255);      
}


You can change the resolution of your circle by changing the PI/1000
value.

Hope this helps,

Matthieu.

-----Message d'origine-----
De : insight-users-bounces at itk.org
[mailto:insight-users-bounces at itk.org] De la part de Ilaria Canova
Calori
Envoyé : lundi 4 avril 2005 15:02
À : insight-users at itk.org
Objet : [Insight-users] Drawing a circle

Dear all,

I would like to create a binary image such as black background and a
white circle, given a specified center and radius.
I was looking at the SphereSpatialFunction but it seems to be
implemented only for 3D.

Any suggestions?

Ilaria Canova Calori

--

_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users





More information about the Insight-users mailing list