MantisBT - ITK
View Issue Details
0005006ITKpublic2007-05-09 18:302007-09-17 12:09
Dan Mueller 
Luis Ibanez 
lowmajoralways
closedfixed 
 
 
0005006: Incorrect NumericTraits for RGBPixel
In Code/Common/itkNumericTraitsRGBPixel.h the ValueType, PrintType, and AbsType for unsigned short is incorrect (it has unsigned char, not unsigned short).

It currently reads:
/** \class NumericTraits<RGBPixel<unsigned short> >
 * \brief Define traits for type RGBPixel<unsigned char>.
 * \ingroup DataRepresentation
 */
template <>
class NumericTraits<RGBPixel<unsigned short> > {
public:
  typedef RGBPixel<unsigned char> ValueType; //<<
  typedef RGBPixel<unsigned char> PrintType; //<<
  typedef RGBPixel<unsigned char> AbsType; //<<
  typedef RGBPixel<unsigned short> AccumulateType;
  typedef RGBPixel<double> RealType;
  typedef double ScalarRealType;
  typedef RGBPixel<float> FloatType;
  static const RGBPixel<unsigned short> ITKCommon_EXPORT Zero;
  static const RGBPixel<unsigned short> ITKCommon_EXPORT One;
  static ValueType ZeroValue() { return Zero; }
  
};

but should read:
/** \class NumericTraits<RGBPixel<unsigned short> >
 * \brief Define traits for type RGBPixel<unsigned short>.
 * \ingroup DataRepresentation
 */
template <>
class NumericTraits<RGBPixel<unsigned short> > {
public:
  typedef RGBPixel<unsigned short> ValueType; //<<
  typedef RGBPixel<unsigned short> PrintType; //<<
  typedef RGBPixel<unsigned short> AbsType; //<<
  typedef RGBPixel<unsigned short> AccumulateType;
  typedef RGBPixel<double> RealType;
  typedef double ScalarRealType;
  typedef RGBPixel<float> FloatType;
  static const RGBPixel<unsigned short> ITKCommon_EXPORT Zero;
  static const RGBPixel<unsigned short> ITKCommon_EXPORT One;
  static ValueType ZeroValue() { return Zero; }
  
};

The comment is also wrong (has char instead of short).

I have attached a file with the correction.
No tags attached.
? itkNumericTraitsRGBPixel.h (2,381) 1969-12-31 19:00
https://public.kitware.com/Bug/file/998/itkNumericTraitsRGBPixel.h
Issue History
2007-09-17 09:07Luis IbanezNote Added: 0009013
2007-09-17 09:07Luis IbanezStatusassigned => acknowledged
2007-09-17 09:12Luis IbanezNote Added: 0009014
2007-09-17 12:09Luis IbanezStatusacknowledged => closed
2007-09-17 12:09Luis IbanezNote Added: 0009026
2007-09-17 12:09Luis IbanezResolutionopen => fixed

Notes
(0007608)
Dan Mueller   
2007-05-09 18:34   
Just thinking, the AccumulateType should probably also be changed from <unsigned short> to <unsigned long>...
(0009013)
Luis Ibanez   
2007-09-17 09:07   
The report is correct,
the RGB traits of "unsigned short" are not defined correctly.

The AccumulateType is also missing to use a larger capacity type.
In order to be consistent with the NumericTraits<unsigned short>
the AccumulateType should use "int".

(0009014)
Luis Ibanez   
2007-09-17 09:12   
The Fix has been committed:
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkNumericTraitsRGBPixel.h?root=Insight&sortby=date&r2=1.10&r1=1.9 [^]
(0009026)
Luis Ibanez   
2007-09-17 12:09   
The Experimental submission from zion passed all the tests.