vendredi 24 avril 2020

error when casting an image to different types in C++

I am trying to use the following sentences to cast an image to different types (the library I am using is ITK 5.1 if it helps):

  if (outputPixelType == std::string("double"))
  {
    using OutputPixelType = double;
  }
  else
  {
    using OutputPixelType = int;
  }

  using OutputImageType = itk::Image<OutputPixelType, Dimension>;

I get an error like this using the compiler clang

  error: use of undeclared identifier 'OutputPixelType'; did you mean 'outputPixelType'?
  using OutputImageType = itk::Image<OutputPixelType, Dimension>;
                                     ^~~~~~~~~~~~~~~
                                     outputPixelType

But if I use the following sentences, it works.

  using OutputPixelType = int;
  using OutputImageType = itk::Image<OutputPixelType, Dimension>;

Why the if statement does not work? How to correct it? Thank you.

Aucun commentaire:

Enregistrer un commentaire