ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkMaskedFFTNormalizedCorrelationImageFilter.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 itkMaskedFFTNormalizedCorrelationImageFilter_h
19 #define itkMaskedFFTNormalizedCorrelationImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkImage.h"
23 
24 namespace itk
25 {
138 
139 template <typename TInputImage, typename TOutputImage, typename TMaskImage=TInputImage >
141  public ImageToImageFilter< TInputImage, TOutputImage >
142 {
143 public:
149 
151  itkNewMacro(Self);
152 
155 
158  itkStaticConstMacro(ImageDimension, unsigned int,
159  TOutputImage::ImageDimension);
160 
162  typedef TInputImage InputImageType;
163  typedef typename InputImageType::RegionType InputRegionType;
164  typedef typename InputImageType::Pointer InputImagePointer;
165  typedef typename InputImageType::ConstPointer InputImageConstPointer;
166  typedef typename InputImageType::SizeType InputSizeType;
168 
169  typedef TOutputImage OutputImageType;
170  typedef typename OutputImageType::Pointer OutputImagePointer;
171  typedef typename OutputImageType::PixelType OutputPixelType;
172 
180 
181  typedef TMaskImage MaskImageType;
182  typedef typename MaskImageType::Pointer MaskImagePointer;
183 
186 
188  void SetFixedImage(const InputImageType *input)
189  {
190  this->SetNthInput(0, const_cast<InputImageType *>(input) );
191  }
193  {
194  return itkDynamicCastInDebugMode<InputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(0)));
195  }
197 
199  void SetMovingImage(const InputImageType *input)
200  {
201  this->SetNthInput(1, const_cast<InputImageType *>(input) );
202  }
204  {
205  return itkDynamicCastInDebugMode<InputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
206  }
208 
210  void SetFixedImageMask(const MaskImageType *input)
211  {
212  this->SetNthInput(2, const_cast<MaskImageType *>(input) );
213  }
215  {
216  return itkDynamicCastInDebugMode<MaskImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(2)));
217  }
219 
222  {
223  this->SetNthInput(3, const_cast<MaskImageType *>(input) );
224  }
226  {
227  return itkDynamicCastInDebugMode<MaskImageType * >(const_cast<DataObject *>(this->ProcessObject::GetInput(3)));
228  }
230 
232  itkSetMacro(RequiredNumberOfOverlappingPixels,SizeValueType);
233  itkGetMacro(RequiredNumberOfOverlappingPixels,SizeValueType);
235 
237  itkGetMacro(RequiredFractionOfOverlappingPixels,RealPixelType);
238  itkSetClampMacro(RequiredFractionOfOverlappingPixels, RealPixelType, 0.0f, 1.0f);
240 
242  itkGetMacro(MaximumNumberOfOverlappingPixels,SizeValueType);
243 
244 #ifdef ITK_USE_CONCEPT_CHECKING
245  // Begin concept checking
246  itkConceptMacro( OutputPixelTypeIsFloatingPointCheck,
248  // End concept checking
249 #endif
250 
251 protected:
253  {
254  this->SetNumberOfRequiredInputs(2);
258  m_AccumulatedProgress = 0.0;
259  }
261  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
262 
264  void VerifyInputInformation() ITK_OVERRIDE;
265 
267  void GenerateData() ITK_OVERRIDE;
268 
274  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
275 
280  void GenerateOutputInformation() ITK_OVERRIDE;
281 
282  void EnlargeOutputRequestedRegion( DataObject *output ) ITK_OVERRIDE;
283 
284  typename TMaskImage::Pointer PreProcessMask( const InputImageType * inputImage, const MaskImageType * inputMask );
285 
286  typename TInputImage::Pointer PreProcessImage( const InputImageType * inputImage, const MaskImageType * inputMask );
287 
288  template< typename LocalInputImageType >
289  typename LocalInputImageType::Pointer RotateImage( LocalInputImageType * inputImage );
290 
291  template< typename LocalInputImageType, typename LocalOutputImageType >
292  typename LocalOutputImageType::Pointer CalculateForwardFFT( LocalInputImageType * inputImage, InputSizeType & FFTImageSize );
293 
294  template< typename LocalInputImageType, typename LocalOutputImageType >
295  typename LocalOutputImageType::Pointer CalculateInverseFFT( LocalInputImageType * inputImage, RealSizeType & combinedImageSize );
296 
297  // Helper math methods.
298  template< typename LocalInputImageType, typename LocalOutputImageType >
299  typename LocalOutputImageType::Pointer ElementProduct( LocalInputImageType * inputImage1, LocalInputImageType * inputImage2 );
300 
301  template< typename LocalInputImageType >
302  typename LocalInputImageType::Pointer ElementQuotient( LocalInputImageType * inputImage1, LocalInputImageType * inputImage2 );
303 
304  template< typename LocalInputImageType >
305  typename LocalInputImageType::Pointer ElementSubtraction( LocalInputImageType * inputImage1, LocalInputImageType * inputImage2 );
306 
307  template< typename LocalInputImageType >
308  typename LocalInputImageType::Pointer ElementPositive( LocalInputImageType * inputImage );
309 
310  template< typename LocalInputImageType, typename LocalOutputImageType >
311  typename LocalOutputImageType::Pointer ElementRound( LocalInputImageType * inputImage );
312 
313  // This function factorizes the image size uses factors of 2, 3, and
314  // 5. After this factorization, if there are any remaining values,
315  // the function returns this value.
316  int FactorizeNumber( int n );
317 
318  // Find the closest valid dimension above the desired dimension. This
319  // will be a combination of 2s, 3s, and 5s.
320  int FindClosestValidDimension( int n );
321 
322  template< typename LocalInputImageType >
323  double CalculatePrecisionTolerance( LocalInputImageType * inputImage );
324 
325 private:
326  MaskedFFTNormalizedCorrelationImageFilter(const Self&); //purposely not implemented
327  void operator=(const Self&); //purposely not implemented
328 
333 
338 
341 
343  const unsigned int m_TotalForwardAndInverseFFTs;
344 
347 };
348 } // end namespace itk
349 
350 #ifndef ITK_MANUAL_INSTANTIATION
351 #include "itkMaskedFFTNormalizedCorrelationImageFilter.hxx"
352 #endif
353 
354 #endif
void EnlargeOutputRequestedRegion(DataObject *output) override
Superclass::RegionType RegionType
Definition: itkImage.h:140
virtual void SetNumberOfRequiredInputs(DataObjectPointerArraySizeType)
Set the number of required indexed inputs.
TMaskImage::Pointer PreProcessMask(const InputImageType *inputImage, const MaskImageType *inputMask)
LocalInputImageType::Pointer ElementSubtraction(LocalInputImageType *inputImage1, LocalInputImageType *inputImage2)
Represent the size (bounds) of a n-dimensional image.
Definition: itkSize.h:52
LocalOutputImageType::Pointer ElementProduct(LocalInputImageType *inputImage1, LocalInputImageType *inputImage2)
Base class for all process objects that output image data.
LocalOutputImageType::Pointer CalculateInverseFFT(LocalInputImageType *inputImage, RealSizeType &combinedImageSize)
unsigned long SizeValueType
Definition: itkIntTypes.h:143
LocalInputImageType::Pointer ElementPositive(LocalInputImageType *inputImage)
LocalOutputImageType::Pointer ElementRound(LocalInputImageType *inputImage)
TInputImage::Pointer PreProcessImage(const InputImageType *inputImage, const MaskImageType *inputMask)
void PrintSelf(std::ostream &os, Indent indent) const override
Superclass::IndexType IndexType
Definition: itkImage.h:122
LocalInputImageType::Pointer RotateImage(LocalInputImageType *inputImage)
virtual void GenerateInputRequestedRegion() override
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Image< std::complex< RealPixelType >, ImageDimension > FFTImageType
LocalInputImageType::Pointer ElementQuotient(LocalInputImageType *inputImage1, LocalInputImageType *inputImage2)
LocalOutputImageType::Pointer CalculateForwardFFT(LocalInputImageType *inputImage, InputSizeType &FFTImageSize)
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Calculate masked normalized cross correlation using FFTs.
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
#define itkConceptMacro(name, concept)
double CalculatePrecisionTolerance(LocalInputImageType *inputImage)
Base class for all data objects in ITK.
Templated n-dimensional image class.
Definition: itkImage.h:75