[Insight-users] Segmentation fault when calling itk::KdTree::Search(queryPoint, radius, neighbors)

motes motes mort.motes at gmail.com
Sat Nov 28 05:47:20 EST 2009


I use the following types to create a KdTree:

  typedef Vector<TScalarType, SpaceDimension>
          VectorType;
  typedef itk::Statistics::ListSample<VectorType>
              SampleType;
  typedef itk::Statistics::KdTreeGenerator< SampleType >
        TreeGeneratorType;
  typedef typename TreeGeneratorType::KdTreeType
         TreeType;
  typedef typename TreeType::InstanceIdentifierVectorType
       NeighborsType;


  typename SampleType::Pointer sample  = SampleType::New();
  typename TreeGeneratorType::Pointer treeGenerator = TreeGeneratorType::New();;
  typename TreeType::Pointer tree;


I create the tree with:

  this->sample->SetMeasurementVectorSize(Dimension);
  VectorType mv;
  for (unsigned int i = 0 ; i < 1000 ; ++i ) {
    mv[0] = (float) i;
    mv[1] = (float) ((1000 - i) / 2 );
    mv[2] = (float) ((1000 - i) / 2 );
    sample->PushBack( mv );
  }

  treeGenerator->SetSample(sample);
  treeGenerator->SetBucketSize(16);
  treeGenerator->Update();
  tree = treeGenerator->GetOutput();






More information about the Insight-users mailing list