[Insight-users] "Killing" itk::kdTree ??
motes motes
mort.motes at gmail.com
Tue Nov 24 20:09:55 EST 2009
I have implemented a transform that calls the itk::kdTree in the
function "TransformPoint":
// Transform a point
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;
// Wraps the call to the kdTree.
this->FindNeighbors(point, m_kernel_radius, neighbors);
...
...
Before running the transform the tree is build with elements. Since
the kdTree is located in the TransformPoint function it gets called
for all pixels in the input image.
I am currently testing it on 128*128*128 images. But when I try to
compute the resampled image I get the error:
HEAP CORRUPTION DETECTED:after Normal block(#107261) at 0x020A44E0.
CRT detected that the application wrote to memory after end of heap
buffer.
as previously described here on the mailing list. Now the wierd thing
is that if I insert a limit in the TransformPoint function like:
if ( m_CoefficientImage[0] ) {
outputPoint.Fill( NumericTraits<ScalarType>::Zero );
// Inserting limit
if(transform_count < transform_limit) {
NeighborContainerType neighbors;
this->FindNeighbors(point, m_kernel_radius, neighbors);
transform_count++;
}
it works fine! I have tried with a transform_limit = 10000 and it
works fine. But if I raise the limit to 100000 I get the above heap
error.
Is it possible to "kill" the itk::kdTree if calling it in a loop that
iterates 100000 times?
More information about the Insight-users
mailing list