[Insight-developers] vectorimage linear interpolation

brian avants stnava at gmail.com
Fri Mar 11 11:36:15 EST 2011


jim

adding

  static const Self ZeroValue()
  {
    return Self(NumericTraits< T >::Zero);
  }

to Common/itkNumericTraitsVariableLengthVectorPixel.h

did the trick.    thanks!

should this go to gerrit?

brian




On Fri, Mar 11, 2011 at 10:22 AM, Jim Miller <millerjv at ge.com> wrote:
> Brian,
> There is a ZeroValue() function in NumericTraits.  Can you utilize that?
> Jim
> On Mar 11, 2011, at 9:05 AM, brian avants wrote:
>
> hi everyone
>
> i'm putting together a registration metric for VectorImages and the
> code reuse from the scalar image metric is very high.  which is great.
>  except there is a small hang up with the
> LinearInterpolateImageFunction.
>
> i am defining:
>
>  typedef itk::VectorImage< float,ImageDimension > ImageType;
>
> and
>
>  typedef LinearInterpolateImageFunction< FixedImageType,
> CoordinateRepresentationType > FixedInterpolatorType;
>
> relevant code from that function is:
>
>  /**
>   * Interpolated value is the weighted sum of each of the surrounding
>   * neighbors. The weight for each neighbor is the fraction overlap
>   * of the neighbor pixel with respect to a pixel centered on point.
>   */
> RealType value= NumericTraits< RealType >::Zero;
>
> so, if i compile with the original code in place, i get this error :
>
> itkLinearInterpolateImageFunction.txx:89: error: invalid conversion
> from ‘const itk::VariableLengthVector<double> (*)(const
> itk::VariableLengthVector<double>&)’ to ‘unsigned int’
> /Users/brianavants/code/ITKv4/ITK/Code/Common/itkLinearInterpolateImageFunction.txx:89:
> error:   initializing argument 1 of
> ‘itk::VariableLengthVector<TValueType>::VariableLengthVector(unsigned
> int) [with TValueType = double]’
>
> the Zero function is defined in
> Common/itkNumericTraitsVariableLengthVectorPixel.h
>
> if i replace
>
>  RealType value= NumericTraits< RealType >::Zero;
>
> with
>
>  RealType value; value.Fill(0);
>
> then all is well for the VectorImage case but this does not work
> (obviously) in the scalar image case.   so, it's this one line / one
> definition that is causing the hang up.  i am hoping someone with more
> familiarity with NumericTraits might point me to the right solution
> i.e. the solution that would let me use the
> LinearInterpolateImageFunction in this context.
>
> for reference, the variable length vector Zero implementation:
>
>  static const Self Zero(const Self  & a)
>  {
>    Self b( a.Size() );
>    b.Fill(NumericTraits< T >::Zero);
>    return b;
>  }
>
> from Common/itkNumericTraitsVariableLengthVectorPixel.h .... any help
> is appreciated.
>
> brian
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>
> Jim Miller
> Senior Scientist
> GE Research
> Interventional and Therapy
> GE imagination at work
>


More information about the Insight-developers mailing list