Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMake/itkExternal_FFTW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ if(NOT ITK_USE_SYSTEM_FFTW)
FFTW3f_LIBRARY_DIRS
${FFTW_STAGED_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
set(FFTW_INCLUDE ${FFTW3_INCLUDE_DIRS})
set(FFTW_INCLUDE ${FFTW3f_INCLUDE_DIRS})

set(PROJ_FFTWD_DEPENDS "fftwf")
endif()
Expand Down
33 changes: 26 additions & 7 deletions Modules/Filtering/FFT/include/itkFFTImageFilterFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,22 @@
#include "itkObjectFactoryBase.h"
#include "itkVersion.h"

#include <type_traits>

namespace itk
{

// Compile-time predicates selecting which precisions a templated FFT filter
// is registered for. Both default to enabled; an FFT backend specializes the
// relevant predicate to std::false_type when its matching precision is
// unavailable (e.g. FFTW without ITK_USE_FFTWD).
template <template <typename, typename> class TFFTImageFilter>
struct FFTImageFilterEnableFloat : std::true_type
{};
template <template <typename, typename> class TFFTImageFilter>
struct FFTImageFilterEnableDouble : std::true_type
{};

/** \class FFTImageFilterTraits
*
* \brief Helper defining pixel traits for templated FFT image filters
Expand Down Expand Up @@ -149,13 +162,19 @@ class FFTImageFilterFactory : public itk::ObjectFactoryBase

FFTImageFilterFactory()
{
OverrideFFTImageFilterType<typename FFTImageFilterTraits<TFFTImageFilter>::template InputPixelType<float>,
typename FFTImageFilterTraits<TFFTImageFilter>::template OutputPixelType<float>>(
typename FFTImageFilterTraits<TFFTImageFilter>::FilterDimensions{});

OverrideFFTImageFilterType<typename FFTImageFilterTraits<TFFTImageFilter>::template InputPixelType<double>,
typename FFTImageFilterTraits<TFFTImageFilter>::template OutputPixelType<double>>(
typename FFTImageFilterTraits<TFFTImageFilter>::FilterDimensions{});
if constexpr (FFTImageFilterEnableFloat<TFFTImageFilter>::value)
{
OverrideFFTImageFilterType<typename FFTImageFilterTraits<TFFTImageFilter>::template InputPixelType<float>,
typename FFTImageFilterTraits<TFFTImageFilter>::template OutputPixelType<float>>(
typename FFTImageFilterTraits<TFFTImageFilter>::FilterDimensions{});
}

if constexpr (FFTImageFilterEnableDouble<TFFTImageFilter>::value)
{
OverrideFFTImageFilterType<typename FFTImageFilterTraits<TFFTImageFilter>::template InputPixelType<double>,
typename FFTImageFilterTraits<TFFTImageFilter>::template OutputPixelType<double>>(
typename FFTImageFilterTraits<TFFTImageFilter>::FilterDimensions{});
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ struct FFTImageFilterTraits<FFTWComplexToComplex1DFFTImageFilter>
using FilterDimensions = std::integer_sequence<unsigned int, 4, 3, 2, 1>;
};

// Disable the precision whose FFTW backend is absent (avoids instantiating an undefined fftw proxy).
#if !defined(ITK_USE_FFTWF)
template <>
struct FFTImageFilterEnableFloat<FFTWComplexToComplex1DFFTImageFilter> : std::false_type
{};
#endif
#if !defined(ITK_USE_FFTWD)
template <>
struct FFTImageFilterEnableDouble<FFTWComplexToComplex1DFFTImageFilter> : std::false_type
{};
#endif

} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "itkComplexToComplex1DFFTImageFilter.hxx"

#include "itkFFTWCommonExtended.h"
// Include fftw3.h directly: the proxy header skips it when first included before ITK_USE_FFTW* is defined.
#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
# include "fftw3.h"
#endif
#include "itkIndent.h"
#include "itkImageLinearConstIteratorWithIndex.h"
#include "itkImageLinearIteratorWithIndex.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include "itkComplexToComplexFFTImageFilter.h"
#include "itkFFTWCommon.h"
// Include fftw3.h directly: the proxy header skips it when first included before ITK_USE_FFTW* is defined.
#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
# include "fftw3.h"
#endif

#include "itkFFTImageFilterFactory.h"

Expand Down Expand Up @@ -161,6 +165,18 @@ struct FFTImageFilterTraits<FFTWComplexToComplexFFTImageFilter>
using FilterDimensions = std::integer_sequence<unsigned int, 4, 3, 2, 1>;
};

// Disable the precision whose FFTW backend is absent (avoids instantiating an undefined fftw proxy).
#if !defined(ITK_USE_FFTWF)
template <>
struct FFTImageFilterEnableFloat<FFTWComplexToComplexFFTImageFilter> : std::false_type
{};
#endif
#if !defined(ITK_USE_FFTWD)
template <>
struct FFTImageFilterEnableDouble<FFTWComplexToComplexFFTImageFilter> : std::false_type
{};
#endif


} // namespace itk

Expand Down
12 changes: 12 additions & 0 deletions Modules/Filtering/FFT/include/itkFFTWForward1DFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ struct FFTImageFilterTraits<FFTWForward1DFFTImageFilter>
using FilterDimensions = std::integer_sequence<unsigned int, 4, 3, 2, 1>;
};

// Disable the precision whose FFTW backend is absent (avoids instantiating an undefined fftw proxy).
#if !defined(ITK_USE_FFTWF)
template <>
struct FFTImageFilterEnableFloat<FFTWForward1DFFTImageFilter> : std::false_type
{};
#endif
#if !defined(ITK_USE_FFTWD)
template <>
struct FFTImageFilterEnableDouble<FFTWForward1DFFTImageFilter> : std::false_type
{};
#endif

} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "itkForward1DFFTImageFilter.hxx"

#include "itkFFTWCommonExtended.h"
// Include fftw3.h directly: the proxy header skips it when first included before ITK_USE_FFTW* is defined.
#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
# include "fftw3.h"
#endif
#include "itkIndent.h"
#include "itkImageLinearConstIteratorWithIndex.h"
#include "itkImageLinearIteratorWithIndex.h"
Expand Down
16 changes: 16 additions & 0 deletions Modules/Filtering/FFT/include/itkFFTWForwardFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "itkForwardFFTImageFilter.h"

#include "itkFFTWCommon.h"
// Include fftw3.h directly: the proxy header skips it when first included before ITK_USE_FFTW* is defined.
#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
# include "fftw3.h"
#endif

#include "itkFFTImageFilterFactory.h"

Expand Down Expand Up @@ -147,6 +151,18 @@ struct FFTImageFilterTraits<FFTWForwardFFTImageFilter>
using FilterDimensions = std::integer_sequence<unsigned int, 4, 3, 2, 1>;
};

// Disable the precision whose FFTW backend is absent (avoids instantiating an undefined fftw proxy).
#if !defined(ITK_USE_FFTWF)
template <>
struct FFTImageFilterEnableFloat<FFTWForwardFFTImageFilter> : std::false_type
{};
#endif
#if !defined(ITK_USE_FFTWD)
template <>
struct FFTImageFilterEnableDouble<FFTWForwardFFTImageFilter> : std::false_type
{};
#endif

} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include "itkHalfHermitianToRealInverseFFTImageFilter.h"
#include "itkFFTWCommon.h"
// Include fftw3.h directly: the proxy header skips it when first included before ITK_USE_FFTW* is defined.
#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
# include "fftw3.h"
#endif

#include "itkFFTImageFilterFactory.h"

Expand Down Expand Up @@ -154,6 +158,18 @@ struct FFTImageFilterTraits<FFTWHalfHermitianToRealInverseFFTImageFilter>
using FilterDimensions = std::integer_sequence<unsigned int, 4, 3, 2, 1>;
};

// Disable the precision whose FFTW backend is absent (avoids instantiating an undefined fftw proxy).
#if !defined(ITK_USE_FFTWF)
template <>
struct FFTImageFilterEnableFloat<FFTWHalfHermitianToRealInverseFFTImageFilter> : std::false_type
{};
#endif
#if !defined(ITK_USE_FFTWD)
template <>
struct FFTImageFilterEnableDouble<FFTWHalfHermitianToRealInverseFFTImageFilter> : std::false_type
{};
#endif

} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
Expand Down
12 changes: 12 additions & 0 deletions Modules/Filtering/FFT/include/itkFFTWInverse1DFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ struct FFTImageFilterTraits<FFTWInverse1DFFTImageFilter>
using FilterDimensions = std::integer_sequence<unsigned int, 4, 3, 2, 1>;
};

// Disable the precision whose FFTW backend is absent (avoids instantiating an undefined fftw proxy).
#if !defined(ITK_USE_FFTWF)
template <>
struct FFTImageFilterEnableFloat<FFTWInverse1DFFTImageFilter> : std::false_type
{};
#endif
#if !defined(ITK_USE_FFTWD)
template <>
struct FFTImageFilterEnableDouble<FFTWInverse1DFFTImageFilter> : std::false_type
{};
#endif

} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "itkInverse1DFFTImageFilter.hxx"

#include "itkFFTWCommonExtended.h"
// Include fftw3.h directly: the proxy header skips it when first included before ITK_USE_FFTW* is defined.
#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
# include "fftw3.h"
#endif
#include "itkIndent.h"
#include "itkImageLinearConstIteratorWithIndex.h"
#include "itkImageLinearIteratorWithIndex.h"
Expand Down
16 changes: 16 additions & 0 deletions Modules/Filtering/FFT/include/itkFFTWInverseFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include "itkInverseFFTImageFilter.h"
#include "itkFFTWCommon.h"
// Include fftw3.h directly: the proxy header skips it when first included before ITK_USE_FFTW* is defined.
#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
# include "fftw3.h"
#endif

#include "itkFFTImageFilterFactory.h"

Expand Down Expand Up @@ -148,6 +152,18 @@ struct FFTImageFilterTraits<FFTWInverseFFTImageFilter>
using FilterDimensions = std::integer_sequence<unsigned int, 4, 3, 2, 1>;
};

// Disable the precision whose FFTW backend is absent (avoids instantiating an undefined fftw proxy).
#if !defined(ITK_USE_FFTWF)
template <>
struct FFTImageFilterEnableFloat<FFTWInverseFFTImageFilter> : std::false_type
{};
#endif
#if !defined(ITK_USE_FFTWD)
template <>
struct FFTImageFilterEnableDouble<FFTWInverseFFTImageFilter> : std::false_type
{};
#endif

} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include "itkRealToHalfHermitianForwardFFTImageFilter.h"
#include "itkFFTWCommon.h"
// Include fftw3.h directly: the proxy header skips it when first included before ITK_USE_FFTW* is defined.
#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
# include "fftw3.h"
#endif

#include "itkFFTImageFilterFactory.h"

Expand Down Expand Up @@ -147,6 +151,18 @@ struct FFTImageFilterTraits<FFTWRealToHalfHermitianForwardFFTImageFilter>
using FilterDimensions = std::integer_sequence<unsigned int, 4, 3, 2, 1>;
};

// Disable the precision whose FFTW backend is absent (avoids instantiating an undefined fftw proxy).
#if !defined(ITK_USE_FFTWF)
template <>
struct FFTImageFilterEnableFloat<FFTWRealToHalfHermitianForwardFFTImageFilter> : std::false_type
{};
#endif
#if !defined(ITK_USE_FFTWD)
template <>
struct FFTImageFilterEnableDouble<FFTWRealToHalfHermitianForwardFFTImageFilter> : std::false_type
{};
#endif

} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ itkComplexToComplex1DFFTImageFilterTest(int argc, char * argv[])
return EXIT_FAILURE;
}

#if defined(ITK_USE_FFTWD)
using PixelType = double;
#else
using PixelType = float;
#endif
const unsigned int Dimension = 2;
using ComplexImageType = itk::Image<std::complex<PixelType>, Dimension>;

Expand Down
4 changes: 4 additions & 0 deletions Modules/Filtering/FFT/test/itkFFT1DImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ itkFFT1DImageFilterTest(int argc, char * argv[])
return EXIT_FAILURE;
}

#if defined(ITK_USE_FFTWD)
using PixelType = double;
#else
using PixelType = float;
#endif
const unsigned int Dimension = 2;

using ImageType = itk::Image<PixelType, Dimension>;
Expand Down
4 changes: 4 additions & 0 deletions Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ itkForward1DFFTImageFilterTest(int argc, char * argv[])
return EXIT_FAILURE;
}

#if defined(ITK_USE_FFTWD)
using PixelType = double;
#else
using PixelType = float;
#endif
const unsigned int Dimension = 2;

using ImageType = itk::Image<PixelType, Dimension>;
Expand Down
4 changes: 4 additions & 0 deletions Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ itkInverse1DFFTImageFilterTest(int argc, char * argv[])
return EXIT_FAILURE;
}

#if defined(ITK_USE_FFTWD)
using PixelType = double;
#else
using PixelType = float;
#endif
const unsigned int Dimension = 2;

using ImageType = itk::Image<PixelType, Dimension>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include "itkPDEDeformableRegistrationFilter.h"
#include "itkMeanSquareRegistrationFunction.h"

#if !defined(ITK_USE_CUFFTW) && (defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD))
// Uses FFTW real-to-real (DCT) transforms, implemented only for double
// precision here, so this filter requires ITK_USE_FFTWD.
#if !defined(ITK_USE_CUFFTW) && defined(ITK_USE_FFTWD)
# include "fftw3.h"

namespace itk
Expand Down Expand Up @@ -136,16 +138,7 @@ class ITK_TEMPLATE_EXPORT CurvatureRegistrationFilter
using DisplacementFieldComponentType = typename DisplacementFieldPixelType::ValueType;
static constexpr unsigned int DeformationVectorDimension = DisplacementFieldPixelType::Dimension;

# if defined(ITK_USE_FFTWD)
// Prefer to use double precision
using RealTypeDFT = double;
# else
# if defined(ITK_USE_FFTWF)
// Allow to use single precision
# warning "Using single precision for FFT computations!"
using RealTypeDFT = double;
# endif
# endif

using DisplacementFieldComponentImageType = Image<RealTypeDFT, TDisplacementField::ImageDimension>;
using DisplacementFieldComponentImagePointer = typename DisplacementFieldComponentImageType::Pointer;
Expand Down Expand Up @@ -213,6 +206,6 @@ class ITK_TEMPLATE_EXPORT CurvatureRegistrationFilter
# include "itkCurvatureRegistrationFilter.hxx"
# endif

#endif // defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
#endif // !defined(ITK_USE_CUFFTW) && defined(ITK_USE_FFTWD)

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*=========================================================================*/
#ifndef itkCurvatureRegistrationFilter_hxx
#define itkCurvatureRegistrationFilter_hxx
#if !defined(ITK_USE_CUFFTW) && (defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD))
#if !defined(ITK_USE_CUFFTW) && defined(ITK_USE_FFTWD)

# include "itkCurvatureRegistrationFilter.h"

Expand Down Expand Up @@ -281,5 +281,5 @@ CurvatureRegistrationFilter<TFixedImage, TMovingImage, TDisplacementField, TImag
}
} // end namespace itk

#endif // defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
#endif // !defined(ITK_USE_CUFFTW) && defined(ITK_USE_FFTWD)
#endif
Loading