ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkPhaseAnalysisImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkPhaseAnalysisImageFilter_h
19#define itkPhaseAnalysisImageFilter_h
20
22#include <itkVectorImage.h>
25#include <itkImage.h>
26#include <itkFixedArray.h>
27namespace itk
28{
63template <typename TInputImage,
65class PhaseAnalysisImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
66{
67public:
68 ITK_DISALLOW_COPY_AND_MOVE(PhaseAnalysisImageFilter);
69
75
77 static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
78
80 itkNewMacro(Self);
81
83 itkOverrideGetNameOfClassMacro(PhaseAnalysisImageFilter);
84
88
89 using InputImagePointer = typename InputImageType::Pointer;
90 using InputImageConstPointer = typename InputImageType::ConstPointer;
91 using InputImageRegionType = typename InputImageType::RegionType;
92 using InputImagePixelType = typename InputImageType::PixelType;
93 using SpacingType = typename InputImageType::SpacingType;
94 using SizeType = typename InputImageRegionType::SizeType;
95
97 using FloatType = typename InputImageType::SpacingValueType;
98
99 using OutputImagePointer = typename OutputImageType::Pointer;
100 using OutputImageConstPointer = typename OutputImageType::ConstPointer;
101 using OutputImageRegionType = typename OutputImageType::RegionType;
103 using OutputImagePixelType = typename OutputImageType::PixelType;
105
108 const OutputImageType *
113
119
125
126protected:
128 ~PhaseAnalysisImageFilter() override = default;
129 void
130 PrintSelf(std::ostream & os, Indent indent) const override;
131
132 void
134 void
135 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
136
139 {
140 const unsigned int & nC = this->GetInput()->GetNumberOfComponentsPerPixel();
142
143 for (unsigned int r = 1; r < nC; r++)
144 {
145 out += inputPixel[r] * inputPixel[r];
146 }
147 return out;
148 }
149
150 /**************** Helpers requiring the square norm of Riesz *******************/
152 ComputeAmplitude(const InputImagePixelType & inputPixel, const OutputImagePixelType & featureAmpSquare) const
153 {
154 return sqrt(inputPixel[0] * inputPixel[0] + featureAmpSquare);
155 }
156
158 ComputePhase(const InputImagePixelType & inputPixel, const OutputImagePixelType & featureAmpSquare) const
159 {
160 return atan2(sqrt(featureAmpSquare), inputPixel[0]);
161 }
162
164 ComputePhaseOrientation(const InputImagePixelType & inputPixel, const OutputImagePixelType & featureAmpSquare) const
165 {
166 // the angles of the polar coordinates of the normed vector:
167 // V = (R1*f, ..., Rn*f) / FeatureNorm
170 OutputImagePixelType fNorm = sqrt(featureAmpSquare);
171 OutputImagePixelType f1Unitary = inputPixel[1] / fNorm;
172 for (unsigned int i = 0; i < ImageDimension - 1; i++)
173 {
174 out[i] = atan2(inputPixel[i + 2] / fNorm, f1Unitary) + ((inputPixel[i + 2] >= 0) ? 0 : itk::Math::pi);
175 }
176 return out;
177 }
178};
179} // end namespace itk
180#ifndef ITK_MANUAL_INSTANTIATION
181# include "itkPhaseAnalysisImageFilter.hxx"
182#endif
183
184#endif
Simulate a standard C array with copy semantics.
Read-only ImageScanlineIterator: ImageScanlineConstIterator<TImage> behaves as ImageScanlineIterator<...
A multi-dimensional iterator templated over image type that walks a region of pixels,...
OutputImageType * GetOutput()
TOutputImage OutputImageType
const InputImageType * GetInput() const
Templated n-dimensional image class.
Definition itkImage.h:89
Control indentation during Print() invocation.
Definition itkIndent.h:53
typename Superclass::InputImageType InputImageType
typename Superclass::OutputImageType OutputImageType
typename InputImageType::SpacingType SpacingType
typename itk::ImageScanlineIterator< OutputImageType > OutputImageRegionIterator
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::RegionType InputImageRegionType
OutputImagePixelType ComputeFeatureVectorNormSquare(const InputImagePixelType &inputPixel) const
SmartPointer< const Self > ConstPointer
typename InputImageType::Pointer InputImagePointer
void BeforeThreadedGenerateData() override
itk::FixedArray< OutputImagePixelType, ImageDimension - 1 > ComputePhaseOrientation(const InputImagePixelType &inputPixel, const OutputImagePixelType &featureAmpSquare) const
~PhaseAnalysisImageFilter() override=default
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
typename OutputImageType::Pointer OutputImagePointer
typename InputImageRegionType::SizeType SizeType
OutputImagePixelType ComputePhase(const InputImagePixelType &inputPixel, const OutputImagePixelType &featureAmpSquare) const
const OutputImageType * GetOutputPhase() const
This ensure that PixelType is float||double, and not complex.
typename InputImageType::SpacingValueType FloatType
typename OutputImageType::RegionType OutputImageRegionType
void PrintSelf(std::ostream &os, Indent indent) const override
ImageToImageFilter< TInputImage, TOutputImage > Superclass
typename itk::ImageScanlineConstIterator< InputImageType > InputImageRegionConstIterator
typename InputImageType::PixelType InputImagePixelType
typename OutputImageType::ConstPointer OutputImageConstPointer
OutputImagePixelType ComputeAmplitude(const InputImagePixelType &inputPixel, const OutputImagePixelType &featureAmpSquare) const
typename InputImageType::ConstPointer InputImageConstPointer
DataObject * GetPrimaryOutput()
Implements transparent reference counting.
#define itkConceptMacro(name, conceptType)
Compile-time check that a template argument satisfies an itk::Concept.
constexpr double pi
Definition itkMath.h:65
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
TTarget itkDynamicCastInDebugMode(TSource x)