Skip to content

ConstImageTypeX cannot be deduced from ImageTypeX #23

Description

@DrLutzi

The following is only a minor inconvenience, and I have provided a workaround on the bottom of the issue.

Probably because of how itk works, the types for images are not the same between their non-const and const version, so instead of using const ImageX, we use ConstImageX. The current problem with this syntax is that the const version of an image cannot be deduced, which can enforce the use of several redundant template members.

Example: in the following code, I want to make a itk filter that inputs an image using an ASTex Image type as a template. The following is perfectly fine:

template<typename TInput> class FilterGetisGI : public itk::ImageToImageFilter<typename TInput::ItkImg, typename TInput::ItkImg>

But it enforces that TInput is a non ConstImageType, because the output of the filter is necessarily non ConstImageType as well. I would like to use something like:

template<typename TNonConstImage> class FilterGetisGI : public itk::ImageToImageFilter<typename TConstImage::ItkImg (?), typename TNonConstImage::ItkImg>

but it is not currently possible to deduce the Const version of an image from its NonConst version. A current workaround is to use something like:

template<typename TNonConstImage, TConstImage> class FilterGetisGI : public itk::ImageToImageFilter<typename TConstImage::ItkImg, typename TNonConstImage::ItkImg>

which forces the user to provide the Const version of the image type with the NonConst.

  • Add a way to deduce const image types from non const image types
  • Add a way to deduce non const image types from const image types

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions