ITK  5.1.0
Insight Toolkit
itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex_h
19 #define itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex_h
20 
22 
23 namespace itk
24 {
113 template <typename TImage>
115 {
116 public:
120 
123  using SizeType = typename Superclass::SizeType;
132 
133  using FrequencyType = typename ImageType::SpacingType;
134  using FrequencyValueType = typename ImageType::SpacingValueType;
138  {
139  this->Init();
140  }
141 
145  : ImageRegionConstIteratorWithIndex<TImage>(ptr, region)
146  {
147  this->Init();
148  }
149 
158  {
159  this->Init();
160  }
161 
162  /*
163  * Image Index [0, N - 1] returns [-N/2 + 1, -1] (negative) union [0 to N/2] (positive). So index N/2 + 1 returns the
164  * 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
165  * stills returns values in the same range.
166  */
167  IndexType
169  {
170  IndexType freqInd;
171 
172  freqInd.Fill(0);
173  for (unsigned int dim = 0; dim < TImage::ImageDimension; dim++)
174  {
175  freqInd[dim] = this->m_PositionIndex[dim] - this->m_ZeroFrequencyIndex[dim];
176  }
177  return freqInd;
178  }
179 
191  GetFrequency() const
192  {
193  FrequencyType freq;
194  IndexType freqInd = this->GetFrequencyBin();
196 
197  for (unsigned int dim = 0; dim < TImage::ImageDimension; dim++)
198  {
199  freq[dim] = this->m_FrequencyOrigin[dim] + this->m_FrequencySpacing[dim] * freqInd[dim];
200  }
201  return freq;
202  }
203 
206  {
207  FrequencyValueType w2(0);
208  FrequencyType w(this->GetFrequency());
209 
210  for (unsigned int dim = 0; dim < TImage::ImageDimension; dim++)
211  {
212  w2 += w[dim] * w[dim];
213  }
214  return w2;
215  }
216 
223  itkGetConstReferenceMacro(ZeroFrequencyIndex, IndexType);
224 
226  itkGetConstReferenceMacro(FrequencyOrigin, FrequencyType);
227 
234  itkGetConstReferenceMacro(FrequencySpacing, FrequencyType);
235 
238  void
240  {
241  this->m_ActualXDimensionIsOdd = value;
242  };
243  itkGetMacro(ActualXDimensionIsOdd, bool);
244  itkBooleanMacro(ActualXDimensionIsOdd);
246 
247 private:
250  void
252  {
253  IndexType minIndex = this->m_Image->GetLargestPossibleRegion().GetIndex();
254  SizeType sizeImage = this->m_Image->GetLargestPossibleRegion().GetSize();
255  for (unsigned int dim = 0; dim < ImageType::ImageDimension; dim++)
256  {
257  this->m_ZeroFrequencyIndex[dim] =
258  static_cast<FrequencyValueType>(minIndex[dim] + std::floor(sizeImage[dim] / 2.0));
259  // Set frequency metadata.
260  // Origin of frequencies is zero in the standard layout of a FFT output.
261  this->m_FrequencyOrigin[dim] = 0.0;
262  // SamplingFrequency = 1.0 / SpatialImageSpacing
263  // Freq_BinSize = SamplingFrequency / Size
264  this->m_FrequencySpacing[dim] = 1.0 / (this->m_Image->GetSpacing()[dim] * sizeImage[dim]);
265  }
266  }
268 
273 };
274 } // end namespace itk
275 #endif
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::Init
void Init()
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:251
itk::ImageRegionConstIteratorWithIndex::PixelType
typename Superclass::PixelType PixelType
Definition: itkImageRegionConstIteratorWithIndex.h:149
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::SetActualXDimensionIsOdd
void SetActualXDimensionIsOdd(bool value)
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:239
itk::ImageConstIteratorWithIndex::SizeType
typename TImage::SizeType SizeType
Definition: itkImageConstIteratorWithIndex.h:109
itkImageRegionConstIteratorWithIndex.h
itk::ImageRegionConstIteratorWithIndex
A multi-dimensional iterator templated over image type that walks an image region and is specialized ...
Definition: itkImageRegionConstIteratorWithIndex.h:128
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex
FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex(const Superclass &it)
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:156
itk::ImageConstIteratorWithIndex::m_Image
TImage::ConstWeakPointer m_Image
Definition: itkImageConstIteratorWithIndex.h:296
itk::ImageRegionConstIteratorWithIndex::PixelContainerPointer
typename Superclass::PixelContainerPointer PixelContainerPointer
Definition: itkImageRegionConstIteratorWithIndex.h:147
itk::ImageConstIteratorWithIndex::PixelContainerPointer
typename PixelContainer::Pointer PixelContainerPointer
Definition: itkImageConstIteratorWithIndex.h:122
itk::ImageRegionConstIteratorWithIndex::ImageType
typename Superclass::ImageType ImageType
Definition: itkImageRegionConstIteratorWithIndex.h:145
itk::ImageConstIteratorWithIndex::PixelType
typename TImage::PixelType PixelType
Definition: itkImageConstIteratorWithIndex.h:128
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex
FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex()
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:136
itk::ImageRegionConstIteratorWithIndex::OffsetType
typename Superclass::OffsetType OffsetType
Definition: itkImageRegionConstIteratorWithIndex.h:143
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::m_ZeroFrequencyIndex
IndexType m_ZeroFrequencyIndex
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:269
itk::ImageConstIteratorWithIndex::IndexType
typename TImage::IndexType IndexType
Definition: itkImageConstIteratorWithIndex.h:105
itk::ImageConstIteratorWithIndex::InternalPixelType
typename TImage::InternalPixelType InternalPixelType
Definition: itkImageConstIteratorWithIndex.h:125
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::m_FrequencyOrigin
FrequencyType m_FrequencyOrigin
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:270
itk::ImageRegionConstIteratorWithIndex::RegionType
typename Superclass::RegionType RegionType
Definition: itkImageRegionConstIteratorWithIndex.h:144
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::FrequencyType
typename ImageType::SpacingType FrequencyType
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:133
itk::ImageConstIteratorWithIndex::AccessorType
typename TImage::AccessorType AccessorType
Definition: itkImageConstIteratorWithIndex.h:132
itk::ImageRegionConstIteratorWithIndex::IndexType
typename Superclass::IndexType IndexType
Definition: itkImageRegionConstIteratorWithIndex.h:141
itk::ImageConstIteratorWithIndex
A base class for multi-dimensional iterators templated over image type that are designed to efficient...
Definition: itkImageConstIteratorWithIndex.h:92
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::IndexType
typename Superclass::IndexType IndexType
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:122
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::GetFrequencyModuloSquare
FrequencyValueType GetFrequencyModuloSquare() const
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:205
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::FrequencyValueType
typename ImageType::SpacingValueType FrequencyValueType
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:134
itk::ImageRegionConstIteratorWithIndex::AccessorType
typename Superclass::AccessorType AccessorType
Definition: itkImageRegionConstIteratorWithIndex.h:150
itk::ImageRegionConstIteratorWithIndex::InternalPixelType
typename Superclass::InternalPixelType InternalPixelType
Definition: itkImageRegionConstIteratorWithIndex.h:148
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex
FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex(const TImage *ptr, const RegionType &region)
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:144
itk::ImageRegionConstIteratorWithIndex::SizeType
typename Superclass::SizeType SizeType
Definition: itkImageRegionConstIteratorWithIndex.h:142
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::GetFrequencyBin
IndexType GetFrequencyBin() const
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:168
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::m_ActualXDimensionIsOdd
bool m_ActualXDimensionIsOdd
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:272
itk::ImageConstIteratorWithIndex::RegionType
typename TImage::RegionType RegionType
Definition: itkImageConstIteratorWithIndex.h:113
itk::ImageConstIteratorWithIndex::m_PositionIndex
IndexType m_PositionIndex
Definition: itkImageConstIteratorWithIndex.h:298
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:114
itk::ImageRegionConstIteratorWithIndex::PixelContainer
typename Superclass::PixelContainer PixelContainer
Definition: itkImageRegionConstIteratorWithIndex.h:146
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::m_FrequencySpacing
FrequencyType m_FrequencySpacing
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:271
itk::ImageConstIteratorWithIndex::ImageType
TImage ImageType
Definition: itkImageConstIteratorWithIndex.h:116
itk::ImageConstIteratorWithIndex::PixelContainer
typename TImage::PixelContainer PixelContainer
Definition: itkImageConstIteratorWithIndex.h:121
itk::FrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex::GetFrequency
FrequencyType GetFrequency() const
Definition: itkFrequencyShiftedFFTLayoutImageRegionConstIteratorWithIndex.h:191
itk::ImageConstIteratorWithIndex::OffsetType
typename TImage::OffsetType OffsetType
Definition: itkImageConstIteratorWithIndex.h:136