InsightSoftwareConsortium / ITKIsotropicWavelets

External Module for ITK, implementing Isotropic Wavelets and Riesz Filter for multiscale phase analysis.
Apache License 2.0
13 stars 11 forks source link

Configure time warnings with wrappings #143

Open phcerdan opened 3 years ago

phcerdan commented 3 years ago

This module works a lot with std::complex , and in StructureTensor each pixel is very small image.

Those cases are not wrapped in ITK, so some API won't be accessible from python.

Generated at configure time with wrappings enabled:

Generating /path/../IsotropicWavelets_snake_case.py
itkMatrixComplex: warning(4): ITK type not wrapped, or currently not known: itk::Vector< std::complex< float >, 2 >
itkMatrixComplex: warning(4): ITK type not wrapped, or currently not known: itk::Point< std::complex< float >, 2 >
itkMatrixComplex: warning(4): ITK type not wrapped, or currently not known: itk::CovariantVector< std::complex< float >, 2 >
itkMatrixComplex: warning(4): ITK type not wrapped, or currently not known: itk::Vector< std::complex< float >, 3 >
itkMatrixComplex: warning(4): ITK type not wrapped, or currently not known: itk::Point< std::complex< float >, 3 >
itkMatrixComplex: warning(4): ITK type not wrapped, or currently not known: itk::CovariantVector< std::complex< float >, 3 >
itkVariableSizeMatrixComplex: warning(4): ITK type not wrapped, or currently not known: itk::Array< std::complex< float > >
itkStructureTensor: warning(4): ITK type not wrapped, or currently not known: itk::GaussianImageSource< itk::Image< double, 3 > >
itkRieszRotationMatrix: warning(4): ITK type not wrapped, or currently not known: itk::Array< std::complex< double > >
phcerdan commented 3 years ago

The following warning will go away if ITK is build with ITK_WRAP_complex_double

itkStructureTensor: warning(4): ITK type not wrapped, or currently not known: itk::GaussianImageSource< itk::Image< double, 3 > >

However, all the core types associates to itkMatrix will still be missing. If we wrap all of them in itkMatrixComplex.wrap.

itk_wrap_class("itk::Vector")
  foreach(d 2 3)
    foreach(t ${WRAP_ITK_COMPLEX_REAL})
      itk_wrap_template("${ITKM_${t}}${d}" "${ITKT_${t}},${d}")
    endforeach()
  endforeach()
itk_end_wrap_class()

itk_wrap_class("itk::Point")
  foreach(d 2 3)
    foreach(t ${WRAP_ITK_COMPLEX_REAL})
      itk_wrap_template("${ITKM_${t}}${d}" "${ITKT_${t}},${d}")
    endforeach()
  endforeach()
itk_end_wrap_class()

itk_wrap_class("itk::CovariantVector")
  foreach(d 2 3)
    foreach(t ${WRAP_ITK_COMPLEX_REAL})
      itk_wrap_template("${ITKM_${t}}${d}" "${ITKT_${t}},${d}")
    endforeach()
  endforeach()
itk_end_wrap_class()

itk_wrap_class("itk::FixedArray")
  foreach(d 2 3)
    foreach(t ${WRAP_ITK_COMPLEX_REAL})
      itk_wrap_template("${ITKM_${t}}${d}" "${ITKT_${t}},${d}")
    endforeach()
  endforeach()
itk_end_wrap_class()

itk_wrap_class("itk::Array")
  foreach(t ${WRAP_ITK_COMPLEX_REAL})
      itk_wrap_template("${ITKM_${t}}" "${ITKT_${t}}")
  endforeach()
itk_end_wrap_class()

itk_wrap_class("itk::Matrix")
  foreach(d 2 3)
    foreach(t ${WRAP_ITK_COMPLEX_REAL})
      itk_wrap_template("${ITKM_${t}}${d}${d}" "${ITKT_${t}},${d},${d}")
    endforeach()
  endforeach()
itk_end_wrap_class()

We face compile time errors because a mix of std::complex<double>and scalar float and viceversa, std::complex<float> and double. And also std::complex<T> with std::complex<T'>.

Modules/Core/Common/include/itkVector.hxx:135:71: error: no match for ‘operator*’ (operand types are ‘itk::FixedArray<std::complex<float>, 3>::ValueType’ {aka ‘std::complex<float>’} and ‘const RealValueType’ {aka ‘const std::complex<double>’})
  135 |     (*this)[i] = static_cast<T>(static_cast<RealValueType>((*this)[i] * inversedNorm))

Modules/Core/Common/include/itkPoint.hxx:215:26: error: no match for ‘operator*’ (operand types are ‘const double’ and ‘const ValueType’ {aka ‘const std::complex<float>’})
  215 |     (*this)[i] += weight * P[N - 1][i];

Some of this errors might be fixed tweaking the itkNumericTraits for std::complex. RealValueType might be changed to be a scalar, not a std::complex.

However, these failures are expected, itkPoint might be conceived as a real point in space, not as a container for other types.