Hi,<br>
<br>
I assume your image is 2D, and create the mask from scratch. Replace
constants by your values.<br>
Didn't even try to compile this so there could be errors but you should
get the idea, you can try and tell me if it works<br><br>Regards <br><br>Iván<br>
<br>
<br>
<span style="font-family: courier new,monospace;">typedef unsigned char
MaskPixelType;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">const unsigned int
Dimension = 2;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">typedef
itk::Image<MaskPixelType,Dimension> MaskImageType;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">// Create mask from
scratch, otherwise copy properties from input image</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MaskImageType::Pointer
mask = MaskImageType::New();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MaskImageType::RegionType::SizeType
maskSize;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">maskSize[0] =
MY_IMAGE_SIZE_X;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">maskSize[1] =
MY_IMAGE_SIZE_Y;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MaskImageType::RegionType::IndexType
maskIndex;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">maskIndex.Fill(0);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MaskImageType::RegionType
maskRegion;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">maskRegion.SetSize(
maskSize );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">maskRegion.SetIndex(
maskIndex );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">mask->SetRegions(
maskRegion );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MaskImageType::SpacingType
maskSpacing;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">maskSpacing.Fill( 1.0
);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">mask->SetSpacing(
maskSpacing );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">mask->Allocate();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">mask->FillBuffer(
itk::NumericTraits<MaskPixelType>::Zero );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MaskImageType::PointType
centerPoint;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">centerPoint[0] =
MY_CENTER_COORD_X;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">centerPoint[1] =
MY_CENTER_COORD_Y;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">typedef
itk::ImageRegionIteratorWithIndex<MaskImageType>
MaskIteratorType;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MaskIteratorType it(
mask, mask->GetRequestedRegion() );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">it.GoToBegin();</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">while( !it.IsAtEnd() )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> const
MaskImageType::IndexType & index = it.GetIndex();</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if( ( index[0] *
spacing[0] - centerPoint[0] ) * ( index[0] * spacing[0] -
centerPoint[0] ) + ( index[1] * spacing[1] - centerPoint[1] ) * (
index[1] * spacing[1] -
centerPoint[1] ) </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <= MY_RADIUS *
MY_RADIUS )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> it.Set</span>( <font face="courier new,monospace">itk::NumericTraits<MaskPixelType>::max()
); // or replace value</font><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ++it;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br>
<br>
<br><div class="gmail_quote">2010/6/11 <span dir="ltr"><<a href="mailto:arpitagrawal@iitb.ac.in">arpitagrawal@iitb.ac.in</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
hey all,<br>
I want to draw a circle of a given radius and center on a binary image...I<br>
cannot get how to use EllipseSpatialObject to do the same...<br>
plz help..<br>
<br>
regards,<br>
Arpit<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>