ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkFrequencyShiftedFFTLayoutImageRegionIteratorWithIndex.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 itkFrequencyShiftedFFTLayoutImageRegionIteratorWithIndex_h
19#define itkFrequencyShiftedFFTLayoutImageRegionIteratorWithIndex_h
20
22
23namespace itk
24{
114template <typename TImage>
116 : public ImageRegionIteratorWithIndex<TImage>
117{
118 template <typename>
120
121public:
125
127 using typename Superclass::IndexType;
128 using typename Superclass::SizeType;
129 using typename Superclass::OffsetType;
130 using typename Superclass::RegionType;
131 using typename Superclass::ImageType;
132 using typename Superclass::PixelContainer;
134 using typename Superclass::InternalPixelType;
135 using typename Superclass::PixelType;
136 using typename Superclass::AccessorType;
137
138 using FrequencyType = typename ImageType::SpacingType;
139 using FrequencyValueType = typename ImageType::SpacingValueType;
146
150 : Superclass(ptr, region)
151 {
152 this->Init();
153 }
154
161 template <
162 typename TOtherImage,
163 std::enable_if_t<detail::IsImageIteratorConvertible_v<TOtherImage, TImage> && !std::is_const_v<TImage>, int> = 0>
169
171 template <
172 typename TOtherImage,
173 std::enable_if_t<detail::IsImageIteratorConvertible_v<TOtherImage, TImage> && std::is_const_v<TImage>, int> = 0>
179
181 template <typename TOtherImage, std::enable_if_t<detail::IsImageIteratorConvertible_v<TOtherImage, TImage>, int> = 0>
190
191 /*
192 * Image Index [0, N - 1] returns [-N/2 + 1, -1] (negative) union [0 to N/2] (positive). So index N/2 + 1 returns the
193 * bin 0. It is a shift by -N/2 + 1, from [0, N-1] to [-N/2 + 1, N/2] If first index of the image is not zero, it
194 * stills returns values in the same range.
195 */
196 [[nodiscard]] IndexType
198 {
199 IndexType freqInd{};
200 for (unsigned int dim = 0; dim < TImage::ImageDimension; ++dim)
201 {
202 freqInd[dim] = this->m_PositionIndex[dim] - this->m_ZeroFrequencyIndex[dim];
203 }
204 return freqInd;
205 }
206
217 [[nodiscard]] FrequencyType
219 {
220 FrequencyType freq;
221 IndexType freqInd = this->GetFrequencyBin();
222
223 for (unsigned int dim = 0; dim < TImage::ImageDimension; ++dim)
224 {
225 freq[dim] = this->m_FrequencyOrigin[dim] + this->m_FrequencySpacing[dim] * freqInd[dim];
226 }
227 return freq;
228 }
229
230 [[nodiscard]] FrequencyValueType
232 {
233 FrequencyValueType w2(0);
234 FrequencyType w(this->GetFrequency());
235
236 for (unsigned int dim = 0; dim < TImage::ImageDimension; ++dim)
237 {
238 w2 += w[dim] * w[dim];
239 }
240 return w2;
241 }
242
249 itkGetConstReferenceMacro(ZeroFrequencyIndex, IndexType);
250
252 itkGetConstReferenceMacro(FrequencyOrigin, FrequencyType);
253
260 itkGetConstReferenceMacro(FrequencySpacing, FrequencyType);
261
265 void
267 {
268 this->m_ActualXDimensionIsOdd = value;
269 }
270 itkGetMacro(ActualXDimensionIsOdd, bool);
271 itkBooleanMacro(ActualXDimensionIsOdd);
273private:
276 void
278 {
279 if (this->m_Image.IsNull())
280 {
281 return;
282 }
283 IndexType minIndex = this->m_Image->GetLargestPossibleRegion().GetIndex();
284 SizeType sizeImage = this->m_Image->GetLargestPossibleRegion().GetSize();
285 for (unsigned int dim = 0; dim < ImageType::ImageDimension; ++dim)
286 {
287 this->m_ZeroFrequencyIndex[dim] =
288 static_cast<FrequencyValueType>(minIndex[dim] + std::floor(sizeImage[dim] / 2.0));
289 // Set frequency metadata.
290 // Origin of frequencies is zero in the standard layout of a FFT output.
291 this->m_FrequencyOrigin[dim] = 0.0;
292 // SamplingFrequency = 1.0 / SpatialImageSpacing
293 // Freq_BinSize = SamplingFrequency / Size
294 this->m_FrequencySpacing[dim] = 1.0 / (this->m_Image->GetSpacing()[dim] * sizeImage[dim]);
295 }
296 }
297
302};
303
304// Deduction guides for class template argument deduction (CTAD).
305template <typename TImage>
308
309template <typename TImage>
312
323template <typename TImage>
341
342// Deduction guides for class template argument deduction (CTAD).
343template <typename TImage>
344FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex(const TImage *, const typename TImage::RegionType &)
346
347template <typename TImage>
350
351template <typename TImage>
354
355} // end namespace itk
356#endif
Read-only FrequencyShiftedFFTLayoutImageRegionIteratorWithIndex: FrequencyShiftedFFTLayoutImageRegion...
FrequencyShiftedFFTLayoutImageRegionIteratorWithIndex< std::add_const_t< TImage > > Superclass
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
FrequencyShiftedFFTLayoutImageRegionIteratorWithIndex(const FrequencyShiftedFFTLayoutImageRegionIteratorWithIndex< TOtherImage > &it)
A base class for multi-dimensional iterators templated over image type that are designed to efficient...
typename PixelContainer::Pointer PixelContainerPointer
detail::IteratorImageType_t< TImage > ImageType
typename TImage::AccessorType AccessorType
typename TImage::InternalPixelType InternalPixelType
typename TImage::PixelContainer PixelContainer
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
FrequencyShiftedFFTLayoutImageRegionIteratorWithIndex(SmartPointer< TImage >, const typename TImage::RegionType &) -> FrequencyShiftedFFTLayoutImageRegionIteratorWithIndex< TImage >
FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex(const TImage *, const typename TImage::RegionType &) -> FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex< TImage >