No subject
Wed Oct 7 22:37:18 EDT 2009
NeighborsType neighbors;
VectorType vectorPoint;
vectorPoint.Fill(0);
for (int i=0; i<NDimensions; i++) {
vectorPoint[i] = point[i];
}
tree->Search(vectorPoint, 10.0, neighbors);
But when I run the application I get a segmentation fault. I have
tried to run the application with Valgrind but I get no error:
valgrind --leak-check=yes --track-origins=yes ./MyApp
INFO:: Computing registered image
==8389==
==8389== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 1)
==8389== malloc/free: in use at exit: 0 bytes in 0 blocks.
==8389== malloc/free: 13,153,309 allocs, 13,153,309 frees,
8,529,290,300 bytes allocated.
==8389== For counts of detected errors, rerun with: -v
==8389== All heap blocks were freed -- no leaks are possible.
I am pretty sure that the problem is the dynamic array 'neighbors'. If
I call the version of Search where the number of neighbors are
specified I don't get any segmentation fault:
NeighborsType neighbors;
VectorType vectorPoint;
vectorPoint.Fill(0);
for (int i=0; i<NDimensions; i++) {
vectorPoint[i] = point[i];
}
unsigned int numberOfNeighbors = 3;
tree->Search( vectorPoint, numberOfNeighbors, neighbors ) ;
But since I need the version where the radius is specified the above
is not an option.
Another thing. The error only occurs when I run a resampling Filter.
If I run the transform through a registration process it works fine.
The resampling Filter is created like this:
typedef itk::ResampleImageFilter< FixedImageType, FixedImageType >
ResampleFilterType;
typedef itk::LinearInterpolateImageFunction< FixedImageType, double >
LinearInterpolatorType;
LinearInterpolatorType::Pointer linearInterpolator =
LinearInterpolatorType::New();
ResampleFilterType::Pointer resampler = ResampleFilterType::New();
resampler->SetInput(imageM);
resampler->SetTransform(adaptiveTransform);
resampler->SetInterpolator(linearInterpolator);
resampler->SetOutputOrigin(imageF->GetOrigin());
resampler->SetOutputSpacing(imageF->GetSpacing());
resampler->SetSize(imageF->GetLargestPossibleRegion().GetSize());
resampler->SetDefaultPixelValue(0);
try {
resampler->Update();
}
catch( itk::ExceptionObject & err ) {
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
}
Any ideas are most welcome!
More information about the Insight-users
mailing list