Hi peter:<br><br>Thanks for your reply.<br>I get the error message using try-catch in following.<br><br>itk::ERROR: RecursiveGaussianImageFilter(01766140): The number of pixels along d<br>irection 2 is less than 4. This filter requires a minimum of four pixels along t
<br>he dimension to be processed.<br><br>Therefore, this problem is due to <br>> size[2] = m_ROIzmax-m_ROIzmin+1;<br>this size must greater than four. <br><br>:)<br><br><br><br><div><span class="gmail_quote">2007/3/30, Peter Cech <
<a href="mailto:pcech@vision.ee.ethz.ch">pcech@vision.ee.ethz.ch</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Fri, Mar 30, 2007 at 00:12:44 +0800, Goo wrote:
<br>> Hi all:<br>><br>> I am trying to extract a region of interest in a image<br>> and using its output as the input of Gradient Filter.<br>><br>> Therefore, the RegionOfInterestImageFilter is used to extract region
<br>> and GradientMagnitudeRecursiveGaussianImageFilter used to count gradient.<br>><br>> but an unknown erorr is occurrence and my program crashed.<br><br>I did not spot anything wrong in the code, but as you did not write
<br>anything more specific about the crash, I'll assume either unhandled<br>exception or segfault. For unhandled exception, put this around your<br>code (I'm putting it around my code in main, so it catches everything):
<br><br><br> try {<br><br> [your code]<br><br> } catch( std::exception & e ) {<br> std::cout << "Exception caught: " << e.what() << std::endl;<br> } catch( ... ) {<br> std::cout << "Unknown exception caught!" << std::endl;
<br> }<br><br><br>It will print out the place and cause of the exception thrown.<br><br>In the case of segfault, I'm afraid the best thing is to run the program<br>in a debugger and try to find what's going on.<br>
<br>Good luck in solving the problem!<br><br>Regards,<br>Peter<br><br>PS: I've just remembered one of my problems with<br>RegionOfInterestImageFilter. The region in question has to be a<br>subregion of input image's region. Do
<br><br> desiredRegion.Crop( m_Cast1->GetOutput()->GetLargestPossibleRegion() );<br><br>before assigning the region for cropping.<br><br><br><br>> My program is following:<br>><br>> typedef float InternalPixelType;
<br>> typedef itk::Image< InternalPixelType, 3> InternalImageType;<br>><br>> typedef signed short OutputPixelType;<br>> typedef itk::Image< OutputPixelType, 3> ExternalImageType;
<br>><br>> typedef itk::RescaleIntensityImageFilter<ExternalImageType,<br>> InternalImageType> InputCastType;<br>> InputCastType::Pointer m_Cast1;<br>><br>> m_Cast1->SetInput( an itk::Image that has ExternalImageType );
<br>> m_Cast1->SetOutputMinimum(0);<br>> m_Cast1->SetOutputMaximum( 255 );<br>><br>> m_Cast1->Update();<br>><br>> typedef itk::RegionOfInterestImageFilter<br>> < InternalImageType , InternalImageType > FilterType;
<br>><br>> FilterType::Pointer ROI1= FilterType::New();<br>><br>> InternalImageType::IndexType start;<br>> start[0] = m_ROIxmin;<br>> start[1] = m_ROIymin;<br>> start[2] = m_ROIzmin;<br>
><br>> InternalImageType::SizeType size;<br>> size[0] = m_ROIxmax-m_ROIxmin+1;<br>> size[1] = m_ROIymax-m_ROIymin+1;<br>> size[2] = m_ROIzmax-m_ROIzmin+1;<br>><br>> InternalImageType::RegionType desiredRegion;
<br>> desiredRegion.SetSize( size );<br>> desiredRegion.SetIndex( start );<br>><br>> ROI1->SetRegionOfInterest( desiredRegion );<br>> ROI1->SetInput(m_Cast1->GetOutput());<br>> ROI1->Update();
<br>><br>> typedef itk::< InternalImageType,InternalImageType ><br>> GradientFilterType;<br>><br>> GradientFilterType::Pointer gradientMagnitude =<br>> GradientFilterType::New();<br>>
<br>> gradientMagnitude->SetSigma( 1 );<br>> gradientMagnitude->SetInput( ROI1->GetOutput() );<br>> gradientMagnitude->Update();<br>><br>><br>> Regards :)<br><br>> _______________________________________________
<br>> Insight-users mailing list<br>> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>> <a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users
</a><br><br></blockquote></div><br>