[Insight-developers] Using ConstantPadImageFilter on vector images

Lydia Ng lng@insightful.com
Thu, 3 Jan 2002 13:20:06 -0800


> I think the Array::operator=3D( const ValueType&) method will=20
> copy this "zero" to all components of an
> Array if PixelType was a subclass of Array. If PixelType is a=20
> scalar, then it should do the right
> thing by default.

Currently Array::operator =3D (const ValueType&) invokes the
"ArrayCommaListCopier".=20

Thus,
itk::Vector<double,2> myVector =3D 3;
will only copy "3" into the first element of myVector.


> -----Original Message-----
> From: Miller, James V (CRD) [mailto:millerjv@crd.ge.com]
> Sent: Thursday, January 03, 2002 5:25 AM
> To: Lydia Ng; Insight-developers (E-mail)
> Subject: RE: [Insight-developers] Using=20
> ConstantPadImageFilter on vector
> images
>=20
>=20
> PixelTraits<PixelType>::Dimension will return the number of=20
> components in a pixel. It returns 1 if
> the pixel is a scalar. This is used in the JoinImageFilter to=20
> determine whether an image has scalar
> or vector data (so that it knows whether operator[] will work or not).
>=20
> PixelTraits<PixelType>::ValueType will return the value type=20
> of a scalar or the value type of a
> component of a vector.
>=20
> So it would seem that the original code in=20
> ConstantPadImageFilter could use
>=20
> PixelType padValue =3D=20
> NumericTraits<PixelTraits<PixelType>::ValueType>::Zero;
>=20
> I think the Array::operator=3D( const ValueType&) method will=20
> copy this "zero" to all components of an
> Array if PixelType was a subclass of Array. If PixelType is a=20
> scalar, then it should do the right
> thing by default.
>=20
>=20
>=20
> -----Original Message-----
> From: Lydia Ng [mailto:lng@insightful.com]
> Sent: Wednesday, January 02, 2002 6:48 PM
> To: Miller, James V (CRD); Insight-developers (E-mail)
> Subject: RE: [Insight-developers] Using=20
> ConstantPadImageFilter on vector
> images
>=20
>=20
> Jim,
>=20
> > Can we change the code so that it tries to use NumericTraits
> > of the "value type" of the pixel?
> >=20
> > One option is to call an overloaded function where the=20
> scalar version
> > returns NumericTraits<PixelType>::Zero and the vector=20
> version returns
> > NumericTraits<PixelType::ValueType>::Zero.
>=20
> Does this option mean that the filter then have to know
> whether or not it is dealing with scalar or vector pixels?
>=20
> The filter will also have to know how big the vector
> is so that it can fill the vector with the appropriate
> number of zeros.
>=20
> -Lydia
>=20
> > -----Original Message-----
> > From: Miller, James V (CRD) [mailto:millerjv@crd.ge.com]
> > Sent: Wednesday, January 02, 2002 2:03 PM
> > To: Lydia Ng; Insight-developers (E-mail)
> > Subject: RE: [Insight-developers] Using=20
> > ConstantPadImageFilter on vector
> > images
> >=20
> >=20
> > Can we change the code so that it tries to use NumericTraits
> > of the "value type" of the pixel?
> >=20
> > One option is to call an overloaded function where the=20
> scalar version
> > returns NumericTraits<PixelType>::Zero and the vector=20
> version returns
> > NumericTraits<PixelType::ValueType>::Zero.
> >=20
> >=20
> >=20
> >=20
> >=20
> > -----Original Message-----
> > From: Lydia Ng [mailto:lng@insightful.com]
> > Sent: Thursday, December 27, 2001 6:11 PM
> > To: Insight-developers (E-mail)
> > Subject: [Insight-developers] Using ConstantPadImageFilter on vector
> > images
> >=20
> >=20
> > Hi All,
> >=20
> > I would like to use ConstantPadImageFilter
> > on vector images (i.e. where the image pixel is
> > of type itk::Vector<someScalar,vectorDimension>).
> >=20
> > The existing implementation does not work because as
> > it requires the used of NumericsTraits<PixelType>::Zero
> > to initialize the padding value to "zero".
> > Currently, NumericsTraits for itk::Vector's are not defined.
> >=20
> > I am not sure how to go about defining a generic
> > NumericsTraits for Vector. Does one have to explicitly
> > specialize NumericsTraits for every combination
> > of *someScalar* and *vectorDimension*?
> >=20
> > My other option is to create a vector version
> > of the filter (i.e. a VectorConstantPadImageFilter) but
> > that seems to be an awful lot of code duplication.
> >=20
> > Any suggestions?
> >=20
> > Cheers,
> > Lydia
> >=20
> >=20
> >=20
> >=20
> > _______________________________________________
> > Insight-developers mailing list
> > Insight-developers@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-developers
> >=20
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>=20