<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Hi Friends,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
When I was trying to call Update() on castimagefilter Iam getting unhandled 
exception.Even though I was using try-catch I was unable to caught the 
exception.</FONT></DIV>
<DIV><FONT face=Arial size=2>If anybody know the solution please help 
me.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>memcpy(Buffer1,Buffer,img_size);</FONT></DIV>
<DIV><FONT face=Arial size=2>typedef float AccumulatorPixelType;<BR>&nbsp;const 
unsigned int Dimension = 2;<BR>&nbsp;<BR>&nbsp;typedef itk::Image&lt; unsigned 
char, Dimension &gt; ImageType;<BR>&nbsp;<BR>&nbsp;typedef itk::Image&lt; 
AccumulatorPixelType, 2 &gt; 
AccumulatorImageType;<BR>&nbsp;AccumulatorImageType::Pointer apointer = 
AccumulatorImageType::New();<BR>&nbsp;typedef ImageType::Pointer 
ImagePointer;<BR>&nbsp;<BR>&nbsp;//BufferToImageConversion<BR>&nbsp;ImagePointer 
image = ImageType::New();&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;int 
SizeArray[3] = {width, height, height};<BR>&nbsp;double spacing[3] = 
{voxelWidth, voxelHeight,voxelDepth};<BR>&nbsp;<BR>&nbsp;ImageType::SizeType 
size ;<BR>&nbsp;for (int 
i=0;i&lt;Dimension;i++)<BR>&nbsp;{<BR>&nbsp;&nbsp;size[i] = 
SizeArray[i];&nbsp;<BR>&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;ImageType::IndexType 
index 
;<BR>&nbsp;index.Fill(0);<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;ImageType::RegionType 
inregion;<BR>&nbsp;inregion.SetSize(size);<BR>&nbsp;inregion.SetIndex(index);<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;image 
-&gt;SetLargestPossibleRegion( inregion );<BR>&nbsp;image 
-&gt;SetBufferedRegion( inregion );<BR>&nbsp;image -&gt;SetRequestedRegion( 
inregion );<BR>&nbsp;image -&gt;SetSpacing(spacing);<BR>&nbsp;image 
-&gt;Allocate();<BR>&nbsp;<BR>&nbsp;itk::ImageRegionIteratorWithIndex&lt;ImageType&gt; 
it(image , inregion);<BR>&nbsp;int k=0;<BR>&nbsp;while( !it.IsAtEnd()) 
<BR>&nbsp;{&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;it.Set(Buffer1[k]);<BR>&nbsp;&nbsp;k++;<BR>&nbsp;&nbsp;++it;<BR>&nbsp;}//End 
Of BufferToImageConversion</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;<BR>&nbsp;typedef 
itk::CastImageFilter&lt;ImageType,AccumulatorImageType&gt;CastingFilterType;<BR>&nbsp;CastingFilterType::Pointer 
caster = CastingFilterType::New();<BR>&nbsp;typedef 
itk::GradientMagnitudeImageFilter&lt;AccumulatorImageType,AccumulatorImageType&gt;GradientFilter;<BR>&nbsp;GradientFilter::Pointer 
gradFilter = GradientFilter::New();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;caster-&gt;SetInput(image);<BR>&nbsp;try 
{<BR>&nbsp;&nbsp;&nbsp; 
caster-&gt;UpdateLargestPossibleRegion();<BR>&nbsp;&nbsp;} <BR>&nbsp;catch ( 
itk::ExceptionObject &amp; err ) <BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
cout&lt;&lt;"ExceptionObject caught";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
cout&lt;&lt;err.GetDescription();<BR>&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;gradFilter-&gt;SetInput(caster-&gt;GetOutput());<BR>&nbsp;gradFilter-&gt;Update();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;typedef 
itk::ThresholdImageFilter&lt;AccumulatorImageType&gt;ThresholdFilterType;<BR>&nbsp;&nbsp;ThresholdFilterType::Pointer 
threshFilter = 
ThresholdFilterType::New();<BR>&nbsp;threshFilter-&gt;SetInput(gradFilter-&gt;GetOutput());<BR>&nbsp;threshFilter-&gt;SetOutsideValue(0);<BR>&nbsp;threshFilter-&gt;ThresholdOutside(ThreshMin,ThreshMax);<BR>&nbsp;threshFilter-&gt;Update();<BR>&nbsp;<BR>&nbsp;//HoughTransformation<BR>&nbsp;typedef 
itk::HoughTransform2DCirclesImageFilter&lt;AccumulatorPixelType 
,AccumulatorPixelType&gt; 
HoughTransformFilterType;<BR>&nbsp;HoughTransformFilterType::Pointer houghFilter 

HoughTransformFilterType::New();<BR>&nbsp;<BR>&nbsp;houghFilter-&gt;SetInput(threshFilter-&gt;GetOutput());<BR>&nbsp;houghFilter-&gt;SetNumberOfCircles( 
NoOfCircles );<BR>&nbsp;houghFilter-&gt;SetMinimumRadius( MinRadius 
);<BR>&nbsp;houghFilter-&gt;SetMaximumRadius( MaxRadius 
);<BR>&nbsp;houghFilter-&gt;SetSweepAngle(m_SweepAngle);<BR>&nbsp;houghFilter-&gt;SetSigmaGradient(m_SigmaGradient);<BR>&nbsp;houghFilter-&gt;SetVariance(m_Variance);<BR>&nbsp;//houghFilter-&gt;SetThreshold(0);<BR>&nbsp;houghFilter-&gt;SetDiscRadiusRatio(m_DiscRadiusRatio);<BR>&nbsp;houghFilter-&gt;Update();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;HoughTransformFilterType::CirclesListType 
circles;<BR>&nbsp;circles = houghFilter-&gt;GetCircles();<BR>&nbsp;typedef 
itk::Image&lt; unsigned char, Dimension &gt; 
OutputImageType;<BR>&nbsp;OutputImageType::Pointer localOutputImage = 
OutputImageType::New();<BR>&nbsp;OutputImageType::IndexType 
localIndex;<BR>&nbsp;OutputImageType::RegionType 
region;<BR>&nbsp;region.SetSize(image-&gt;GetLargestPossibleRegion().GetSize());<BR>&nbsp;region.SetIndex(image-&gt;GetLargestPossibleRegion().GetIndex());<BR>&nbsp;localOutputImage-&gt;SetRegions( 
region 
);<BR>&nbsp;localOutputImage-&gt;SetOrigin(image-&gt;GetOrigin());<BR>&nbsp;localOutputImage-&gt;SetSpacing(image-&gt;GetSpacing());<BR>&nbsp;localOutputImage-&gt;Allocate();<BR>&nbsp;localOutputImage-&gt;FillBuffer(0);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;typedef 
HoughTransformFilterType::CirclesListType 
CirclesListType;<BR>&nbsp;CirclesListType::const_iterator itCircles = 
circles.begin();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;while( itCircles != circles.end() 
)<BR>&nbsp;{<BR>&nbsp;<BR>&nbsp;&nbsp;for(double angle = 0;angle &lt;= 
2*vnl_math::pi; angle += vnl_math::pi/60.0 )<BR>&nbsp;&nbsp;{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;localIndex[0] = (long 
int)((*itCircles)-&gt;GetObjectToParentTransform()-&gt;GetOffset()[0]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//+ 
(*itCircles)-&gt;GetRadius()[0]*cos(angle));<BR>&nbsp;&nbsp;localIndex[1] = 
(long 
int)((*itCircles)-&gt;GetObjectToParentTransform()-&gt;GetOffset()[1]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//+ 
(*itCircles)-&gt;GetRadius()[0]*sin(angle));<BR>&nbsp;&nbsp;OutputImageType::RegionType 
region = localOutputImage-&gt;GetLargestPossibleRegion();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;if( region.IsInside( localIndex ) 
)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;localOutputImage-&gt;SetPixel( 
localIndex, 255 
);<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;itCircles++;<BR>&nbsp;}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;OutBuffer = 
localOutputImage-&gt;GetBufferPointer();//end of 
houghtransformation<BR>&nbsp;for(int 
k=0;k&lt;65536;k++)<BR>&nbsp;&nbsp;if(OutBuffer[k]!=0)<BR>&nbsp;&nbsp;&nbsp;OutBuffer[k]=255;</FONT></DIV></BODY></HTML>