[Insight-users] Cannot run the Resampling filter

motes motes mort.motes at gmail.com
Wed Nov 25 20:44:29 EST 2009


Which objects survive in the transform component when the image
registration method is finished?

By finished I mean reaches the scope after this try/catch block:

    try {
      registration->Update();
    }
    catch( itk::ExceptionObject & err ) {
      std::cerr << "ExceptionObject caught !" << std::endl;
      std::cerr << err << std::endl;
      return EXIT_FAILURE;
    }

// What lives in the image registration method when arriving here?





The reason I ask is because I am trying to compute the registered
image AFTER the registration method is done. Something like this:

    try {

      registration->Update();
    }
    catch( itk::ExceptionObject & err ) {
      std::cerr << "ExceptionObject caught !" << std::endl;
      std::cerr << err << std::endl;
      return EXIT_FAILURE;
    }

    computeRegisteredImage();
    return EXIT_SUCCESS;


where:

  void computeRegisteredImage(){
    ResampleFilterType::Pointer resampler = ResampleFilterType::New();
    resampler->SetInput(imageM);
    resampler->SetTransform(registration->GetTransform());
    resampler->SetInterpolator(registration->GetInterpolator());
    resampler->SetOutputOrigin(imageF->GetOrigin());
    resampler->SetOutputSpacing(imageF->GetSpacing());
    resampler->SetSize(imageF->GetLargestPossibleRegion().GetSize());
    resampler->SetDefaultPixelValue(default_pixel_value);
    try {
      resampler->Update();
    }
    catch( itk::ExceptionObject & err ) {
      std::cerr << "ExceptionObject caught !" << std::endl;
      std::cerr << err << std::endl;
    }


    imageR = resampler->GetOutput();


  }



But:

resampler->Update();

never returns. It thows a segmentation fault. I have located the error
to be in the TransformPoint method. I have made my own transform which
uses a kdTree in the TransformPoint function. This kdTree is stored
locally in my transform like:


#include "kd_tree.h" // My own itk:kdTree wrapper.
namespace itk
{
template <
    class TScalarType = double,          // Data type for scalars
    unsigned int NDimensions = 3,        // Number of dimensions
    unsigned int VSplineOrder = 3 >      // Spline order
class ITK_EXPORT MyDeformableTransform :
          public Transform< TScalarType, NDimensions, NDimensions >
{
public:
  /** Standard class typedefs. */
  typedef MyDeformableTransform                                          Self;
...
...
...

  typedef KdTree<VectorType, ControlPointContainerType, NDimensions>
               KdTreeType;


....
.....
...
protected:
  mutable KdTreeType m_kdTree;





Can this have something to do with the segmentation error? Does it
need to be stored as a smart pointer instead?







In the TransformPoint function I do:

// Transform a point
template<class TScalarType, unsigned int NDimensions, unsigned int VSplineOrder>
void
MyDeformableTransform<TScalarType, NDimensions, VSplineOrder>
::TransformPoint(
  const InputPointType & point,
  OutputPointType & outputPoint,
  WeightsType & weights,
  ParameterIndexArrayType & indices,
  bool & inside ) const
{
  unsigned int j;
  IndexType supportIndex;
  inside = true;
  InputPointType transformedPoint;

  if ( m_BulkTransform ) {
    transformedPoint = m_BulkTransform->TransformPoint( point );
  } else {
    transformedPoint = point;
  }

  outputPoint.Fill( NumericTraits<ScalarType>::Zero );
  if ( GetNumberOfParameters()>0) {
    outputPoint.Fill( NumericTraits<ScalarType>::Zero );



     NeighborContainerType neighbors;

      // This results in a segmentation error
      this->FindNeighbors(point, m_kernel_radius, neighbors);



its the call:

      this->FindNeighbors(point, m_kernel_radius, neighbors);

that gives the error which basically just calls the itk::kdTree class.

Any suggestions are most welcome!


More information about the Insight-users mailing list