[Insight-developers] transform internal types

Stefan Klein s.klein at erasmusmc.nl
Wed May 5 05:15:57 EDT 2010


Hi Marius,

If you want to make the parametersValueType a template parameter, then 
that also has consequences for the 
ImageToImageMetric->GetValue/GetDerivative functions, (so the 
ImageToImageMetric should also become templated over the 
ParametersValueType), and the Optimizers. I don't think that's desirable.

Kind regards,
Stefan

On 4-5-2010 16:43, M.Staring at lumc.nl wrote:
> Hi all,
>
> I have a question about the internal floating types that are used in the
> itk::TransformBase and the itk::Transform classes.
>
> Currently, the TransformBase contains the typedef:
>
>    typedef  double  ParametersValueType;
>
> and the Transform:
>
>    typedef  Array2D<  double>   JacobianType;
>
> So, the ParametersType and the JacobianType are hard-coded to be
> doubles.
>
> For my application I like them to be floats.
>
> It seems intuitive to use the first template parameter of the Transform
> class for this. This template parameter namely is a PrecisionType /
> ScalarType. This PrecisionType then defines the type of for example the
> input and output points, the rotation matrix for the affine transform,
> and the B-spline weights function type of the B-spline transform. So, in
> the end it determines the precision of the output, regardless of the
> ParametersType being doubles.
>
> For example:
> - The SetParameters() function in the MatrixOffsetTransformBase copies
> the parameters to m_Matrix, which is defined as
>    typedef Matrix<TScalarType, OutputSpaceDimension, InputSpaceDimension>
> MatrixType;
> so, defined as a float matrix if I choose TScalarType = float. The added
> precision of the parameters being double is immediately thrown away.
>
> Of course, using a double type can sometimes add some precision for
> intermediate computations. However, it would be nice to be able to use
> floats if for a specific application float precision is all what is
> needed. But mainly, I would like to pass the parameters to the GPU, and
> not all GPUs support double precision.
>
>
>
> Is there a reason that ParametersValueType and JacobianType are
> hard-coded to be doubles ?
>
> -------------------------
>
> A solution to fix this would be to move the ParametersValueType typedef
> from the TransformBase to the Transform and change it to:
>
>    typedef  TScalarType  ParametersValueType;
>
> And also change
>    typedef  Array2D<  TScalarType>   JacobianType;
>
> But I guess that would break backwards compatibility. A solution to that
> could be the use of a cmake variable and some #ifdefs.
>
> Does anyone see objections to these changes, or can you recommend a
> better fix?
>
> Regards,
>
> Marius Staring
> _______________________________________________
> 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
>    


More information about the Insight-developers mailing list