ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkFrequencyImageRegionConstIteratorWithIndex.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 itkFrequencyImageRegionConstIteratorWithIndex_h
19 #define itkFrequencyImageRegionConstIteratorWithIndex_h
20 
22 
23 namespace itk
24 {
74 template< typename TImage >
76  public ImageRegionConstIteratorWithIndex< TImage >
77 {
78 public:
82 
84  using IndexType = typename Superclass::IndexType;
85  using SizeType = typename Superclass::SizeType;
88  using ImageType = typename Superclass::ImageType;
92  using PixelType = typename Superclass::PixelType;
94 
95  using FrequencyType = typename ImageType::SpacingType;
96  using FrequencyValueType = typename ImageType::SpacingValueType;
100  {
101  this->Init();
102  }
103 
106  FrequencyImageRegionConstIteratorWithIndex(const TImage *ptr, const RegionType & region) :
107  ImageRegionConstIteratorWithIndex< TImage >(ptr, region)
108  {
109  this->Init();
110  }
111 
120  {
121  this->Init();
122  }
123 
124  /*
125  * The image is in the frequency domain already, return the index.
126  */
128  {
129  return this->GetIndex();
130  }
131 
132  /* Similar to TransformIndexToPhysicalPoint on GetIndex(),
133  * but the result is cast to FrequencyType. And direction is not taken into account.
134  */
136  {
137  FrequencyType freq;
138  IndexType freqInd = this->GetFrequencyBin();
139  // FrequencyType freq;
140  for (unsigned int dim = 0; dim < TImage::ImageDimension; dim++)
141  {
142  freq[dim] = this->m_FrequencyOrigin[dim]
143  + this->m_FrequencySpacing[dim] * freqInd[dim];
144  }
145  return freq;
146  }
147 
149  {
150  FrequencyValueType w2(0);
151  FrequencyType w( this->GetFrequency() );
152 
153  for (unsigned int dim = 0; dim < TImage::ImageDimension; dim++)
154  {
155  w2 += w[dim] * w[dim];
156  }
157  return w2;
158  }
159 
161  itkGetConstReferenceMacro(FrequencyOrigin, FrequencyType);
162 
165  itkGetConstReferenceMacro(FrequencySpacing, FrequencyType);
166 
167 private:
170  void Init()
171  {
172  this->m_FrequencyOrigin = this->m_Image->GetOrigin();
173  this->m_FrequencySpacing = this->m_Image->GetSpacing();
174  }
176 
179 };
180 } // end namespace itk
181 #endif
FrequencyImageRegionConstIteratorWithIndex(const TImage *ptr, const RegionType &region)
typename PixelContainer::Pointer PixelContainerPointer
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
typename TImage::InternalPixelType InternalPixelType
A multi-dimensional iterator templated over image type that walks an image region and is specialized ...
A base class for multi-dimensional iterators templated over image type that are designed to efficient...
typename Superclass::PixelContainerPointer PixelContainerPointer
typename TImage::PixelContainer PixelContainer
typename Superclass::InternalPixelType InternalPixelType