[Insight-developers] Registration Valgrind Issues: itkVectorResampleImageFilter.hxx, UMR m_DefaultPixelValue

Luis Ibanez luis.ibanez at kitware.com
Sun Aug 14 17:49:36 EDT 2011


Hi Brian,

On Sun, Aug 14, 2011 at 11:16 AM, brian avants <stnava at gmail.com> wrote:
> hi luis
>
> jeff duda has been working on this and what you found is clearly a
> bug, of course.
>
> we had a similar issue in the linear interpolator and, if i am
> recalling correctly, the solution you propose:
>
>> m_DefaultPixelValue = NumericTraits< PixelType >::ZeroValue(
>> m_DefaultPixelValue );
>
> does something reasonable.   but with variable length vectors, the
> issue is that we do not know the size of the vector until run time.


That's the reason why ZeroValue() takes an argument.
It is intended to take the size of the vector from that argument.

In the particular case of this constructor initialization, this is circular,
but in the general case of zeroing the variable, the trick should work.

> in the case of the linear interpolator, we were able to identify this
> through a 'trick' using the boolean firstOverlap (which senses that
> it's the first pixel we've seen and thus stores the value):
>
> from ITK//Modules/Core/ImageFunction/include/itkLinearInterpolateImageFunction.hxx
>
>      if( firstOverlap )
>        {
>        // Performing the first assignment of value like this allows
>        // VariableLengthVector type to be resized properly.
>        value = static_cast< RealType >
>          ( this->GetInputImage()->GetPixel(neighIndex) ) * overlap;
>        firstOverlap = false;
>        }
>
> this allowed us to have a linear interpolator that worked on both
> scalar and variable length vector images.
>
> not sure if it's relevant here as well but it could be -  i.e. we
> could allow the default pixel value to be unknown until we actually
> have a pixel ... then we could fill it with a zero vector of the
> correct size.   of course, this assumes the size is constant across
> the image.
>

Yeap, that's an existing assumption.
All pixels in a given image will have the
same number of components.


    Luis


More information about the Insight-developers mailing list