[Insight-users] reading unknown transform - how to itk::TransformFactory<TransformType>::RegisterTransform(); ???

Luis Ibanez luis.ibanez at kitware.com
Mon Oct 19 13:48:03 EDT 2009


Hi Darren,

What do you call an "Unkown" transform ?

An ITK transform of a well defined type, but whose actual type is not currently
known to the application user ?

If so, then you (as a developer) will have to implement a cascade of
reading attempts for all the Transform types that are supported by
your application.

The factory makes easier for you to register all those potential
readers, and to try them in sequence.

This is a similar situation to reading an image from a file without
knowing in advance what is the specific  pixel type of that image.


I have to admit that the resulting code is not going to be pretty....

However, the only way to simplify it would be to have a predefined
list of the transform that your application support, and then package
the reading process into a single function.


    Regards,


           Luis


---------------------------------------------------------------------------------------------
On Tue, Oct 13, 2009 at 6:01 PM, Darren Weber
<darren.weber.lists at gmail.com> wrote:
>
> With regard to reading a transform file, using itk::TransformFileReader,
> given the example:
> examples/IO/TransformReadWrite.cxx
>
> This example uses the following code to register and read a known
> BSplineTransformType, i.e.:
>
> typedef itk::BSplineDeformableTransform<double,3,5> BSplineTransformType;
> ...
> itk::TransformFileReader::Pointer reader;
> reader = itk::TransformFileReader::New();
> // Some transforms (like the BSpline transform) might not be registered
> // with the factory so we add them manually.
> itk::TransformFactory<BSplineTransformType>::RegisterTransform();
> reader->SetFileName( "Transforms.meta" );
> try
>     {
>     reader->Update();
>     }
> catch( itk::ExceptionObject & excp )
>     {
>     std::cerr << "Error while reading the transform file" << std::endl;
>     std::cerr << excp << std::endl;
>     std::cerr << "[FAILED]" << std::endl;
>     return EXIT_FAILURE;
>     }
>
>
> Now let's assume a transform file contains an unknown transform type.
>
> What is the role of the transform factory?  Is it required to read a
> transform file?  Is it possible to read a unknown transform file and
> register a given transform type with the transform factory after reading the
> file?
>
> Suppose the transform file contains a BSplineTransformType, but the
> parameters are unknown.  Is it possible to read this transform file?
>
> TIA and take care,
> Darren
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.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-users
>
>


More information about the Insight-users mailing list