Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polymorphic pixel type reader #7

Open
pieper opened this issue May 30, 2017 · 4 comments
Open

polymorphic pixel type reader #7

pieper opened this issue May 30, 2017 · 4 comments

Comments

@pieper
Copy link

pieper commented May 30, 2017

When using an ITK reader one needs to specify a pixel type, but many file formats, including DICOM, are polymorphic and the actual data type is only known by reading the file.

Slicer includes a layer that queries the data type and then uses macros so that the native data type of the file can be returned. This is all implemented in the VTK code that wraps ITK, such as these examples:

https://github.com/Slicer/Slicer/blob/master/Libs/vtkITK/vtkITKArchetypeImageSeriesReader.cxx#L190

https://github.com/Slicer/Slicer/blob/dac2a3d60e91aeee5912751509455be2217f69fd/Libs/vtkITK/vtkITKArchetypeImageSeriesScalarReader.cxx#L90

It would be great if ITK implemented a more native support for this pattern to simplify the logic for users of the code.

This was discussed as an issue on the Slicer forum topic here:

https://discourse.slicer.org/t/slicer-dicom-scalar-volume-plugin-relies-on-old-gdcm-why-do-we-not-use-dcmtk/354/11

@jcfr
Copy link
Contributor

jcfr commented May 30, 2017

@fbudin69500 Do you think the approach implemented in ITKPython could be generalized ?

@fbudin69500
Copy link
Collaborator

The advantage of ITKPython is that it is... in Python. So wrapping all the possible types is possible (see 1).
In C++, the problem comes with the templates. @pieper : In the example you shared, it seems that you are wrapping only scalar types. I used a similar paradigm (macros) to wrap more types (see 2 and 3). [2] is difficult to read and applied to a complex case, but something similar could be done in ITK. [3] is a more straightforward reader. The example I shared supports scalar, vector, and RGB/RGBA images. One could extend it to other types of images too.

@pieper
Copy link
Author

pieper commented May 31, 2017 via email

@thewtex
Copy link
Member

thewtex commented May 31, 2017

@pieper thanks for adding the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants