[Insight-users] Connection between RegionOfInterestImageFilter and GradientMagnitudeRecursiveGaussianImageFilter

Peter Cech pcech at vision.ee.ethz.ch
Thu Mar 29 11:48:46 EST 2007


On Fri, Mar 30, 2007 at 00:12:44 +0800, Goo wrote:
> Hi all:
> 
> I am trying to extract a region of interest in a image
> and using its output as the input of Gradient Filter.
> 
> Therefore, the RegionOfInterestImageFilter is used to extract region
> and GradientMagnitudeRecursiveGaussianImageFilter used to count gradient.
> 
> but an unknown erorr is occurrence and my program crashed.

I did not spot anything wrong in the code, but as you did not write
anything more specific about the crash, I'll assume either unhandled
exception or segfault. For unhandled exception, put this around your
code (I'm putting it around my code in main, so it catches everything):


  try {

    [your code]

  } catch( std::exception & e ) {
    std::cout << "Exception caught: " << e.what() << std::endl;
  } catch( ... ) {
    std::cout << "Unknown exception caught!" << std::endl;
  }


It will print out the place and cause of the exception thrown.

In the case of segfault, I'm afraid the best thing is to run the program
in a debugger and try to find what's going on.

Good luck in solving the problem!

Regards,
Peter

PS: I've just remembered one of my problems with
RegionOfInterestImageFilter. The region in question has to be a
subregion of input image's region. Do

  desiredRegion.Crop( m_Cast1->GetOutput()->GetLargestPossibleRegion() );

before assigning the region for cropping.



> My program is following:
> 
>    typedef    float           InternalPixelType;
>    typedef itk::Image< InternalPixelType, 3>  InternalImageType;
> 
>    typedef    signed short    OutputPixelType;
>    typedef itk::Image< OutputPixelType, 3>    ExternalImageType;
> 
>    typedef itk::RescaleIntensityImageFilter<ExternalImageType,
> InternalImageType> InputCastType;
>    InputCastType::Pointer m_Cast1;
> 
>    m_Cast1->SetInput(    an itk::Image that has ExternalImageType   );
>    m_Cast1->SetOutputMinimum(0);
>    m_Cast1->SetOutputMaximum( 255 );
> 
>    m_Cast1->Update();
> 
>    typedef itk::RegionOfInterestImageFilter
>        < InternalImageType , InternalImageType > FilterType;
> 
>    FilterType::Pointer ROI1= FilterType::New();
> 
>    InternalImageType::IndexType start;
>    start[0] = m_ROIxmin;
>    start[1] = m_ROIymin;
>    start[2] = m_ROIzmin;
> 
>    InternalImageType::SizeType size;
>    size[0] = m_ROIxmax-m_ROIxmin+1;
>    size[1] = m_ROIymax-m_ROIymin+1;
>    size[2] = m_ROIzmax-m_ROIzmin+1;
> 
>    InternalImageType::RegionType desiredRegion;
>    desiredRegion.SetSize(  size  );
>    desiredRegion.SetIndex( start );
> 
>    ROI1->SetRegionOfInterest( desiredRegion );
>    ROI1->SetInput(m_Cast1->GetOutput());
>    ROI1->Update();
> 
>    typedef itk::< InternalImageType,InternalImageType >
> GradientFilterType;
> 
>    GradientFilterType::Pointer        gradientMagnitude =
> GradientFilterType::New();
> 
>    gradientMagnitude->SetSigma(  1 );
>    gradientMagnitude->SetInput( ROI1->GetOutput() );
>    gradientMagnitude->Update();
> 
> 
> Regards :)

> _______________________________________________
> 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