[Insight-users] HEAP CORRUPTION DETECTED:after Normal block ....
motes motes
mort.motes at gmail.com
Tue Nov 24 16:08:22 EST 2009
I am starting to get some rather nasty memory related errors in my itk
application. The error message is:
HEAP CORRUPTION DETECTED:after Normal block(#107261) at 0x020A44E0.
CRT detected that the application wrote to memory after end of heap
buffer.
It happens when I try to compute the registered image after the
registration process is finished. The code for this looks like this:
void computeRegisteredImage(){
std::cout << "INFO:: Computing registered image" << std::endl;
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);
resampler->Update();
CopyImageToImage<typename FixedImageType::Pointer,
FixedImageType>(resampler->GetOutput(), imageR);
}
Now the resampler uses the transform. I have created my own transform
that make use of the itk::kdtree:
template<class TScalarType, unsigned int NDimensions, unsigned int VSplineOrder>
void
MyTransform<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 ( m_CoefficientImage[0] ) {
outputPoint.Fill( NumericTraits<ScalarType>::Zero );
NeighborContainerType neighbors;
this->FindNeighbors(point, m_kernel_radius, neighbors);
where FindNeighbors is:
template<typename TScalarType, unsigned int NDimensions, unsigned int
VSplineOrder>
void
MyTransform<TScalarType, NDimensions, VSplineOrder>
::FindNeighbors(const InputPointType & point, double radius,
NeighborContainerType & neighborControlPoints) const
{
VectorContainerType neighbors;
InputPointType tmp;
tmp.Fill( NumericTraits<ScalarType>::Zero );
VectorType vectorPoint = point - tmp;
m_kdTree.search(vectorPoint, radius, neighbors);
and search is:
void search(MeasurementVectorType & queryPoint, double & radius,
NeighborContainerType & neighborsContainer) {
NeighborsType neighbors;
tree->Search(queryPoint, radius, neighbors );
It works fine when I use it during the registration process but not
when it come to the resampling process. Any ideas on what might be
causing this kind of error and how to locate it?
More information about the Insight-users
mailing list