ITK  6.0.0
Insight Toolkit
itkBlockMatchingImageFilter.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 itkBlockMatchingImageFilter_h
19 #define itkBlockMatchingImageFilter_h
20 
21 #include "itkMeshToMeshFilter.h"
22 #include "itkImage.h"
23 #include "itkPointSet.h"
24 #include "itkVector.h"
26 
27 #include <memory> // For unique_ptr.
28 
29 namespace itk
30 {
72 template <
73  typename TFixedImage,
74  typename TMovingImage = TFixedImage,
75  typename TFeatures = PointSet<Matrix<SpacePrecisionType, TFixedImage::ImageDimension, TFixedImage::ImageDimension>,
76  TFixedImage::ImageDimension>,
77  class TDisplacements =
78  PointSet<Vector<typename TFeatures::PointType::ValueType, TFeatures::PointDimension>, TFeatures::PointDimension>,
79  class TSimilarities = PointSet<SpacePrecisionType, TDisplacements::PointDimension>>
80 class ITK_TEMPLATE_EXPORT BlockMatchingImageFilter : public MeshToMeshFilter<TFeatures, TDisplacements>
81 {
82 public:
83  ITK_DISALLOW_COPY_AND_MOVE(BlockMatchingImageFilter);
84 
85  static constexpr unsigned int ImageDimension = TFixedImage::ImageDimension;
86 
91 
93  using FixedImageType = TFixedImage;
95  using FixedImagePixelType = typename FixedImageType::PixelType;
96 
98  using MovingImageType = TMovingImage;
100 
102  using FeaturePointsType = TFeatures;
106 
108  using DisplacementsType = TDisplacements;
111  using DisplacementsVector = typename DisplacementsType::PixelType;
112 
114  using SimilaritiesType = TSimilarities;
117  using SimilaritiesValue = typename SimilaritiesType::PixelType;
118 
124 
126  itkNewMacro(Self);
127 
129  itkOverrideGetNameOfClassMacro(BlockMatchingImageFilter);
130 
132  itkSetMacro(BlockRadius, ImageSizeType);
133  itkGetConstMacro(BlockRadius, ImageSizeType);
137  itkSetMacro(SearchRadius, ImageSizeType);
138  itkGetConstMacro(SearchRadius, ImageSizeType);
142  itkSetInputMacro(FixedImage, FixedImageType);
143  itkGetInputMacro(FixedImage, FixedImageType);
147  itkSetInputMacro(MovingImage, MovingImageType);
148  itkGetInputMacro(MovingImage, MovingImageType);
152  itkSetInputMacro(FeaturePoints, FeaturePointsType);
153  itkGetInputMacro(FeaturePoints, FeaturePointsType);
156  inline DisplacementsType *
158  {
159  return dynamic_cast<DisplacementsType *>(this->ProcessObject::GetOutput(0));
160  }
161 
162  inline SimilaritiesType *
164  {
165  return dynamic_cast<SimilaritiesType *>(this->ProcessObject::GetOutput(1));
166  }
167 
169  using Superclass::MakeOutput;
171  MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override;
172 
173 protected:
178  void
179  GenerateOutputInformation() override;
180 
182  void
183  EnlargeOutputRequestedRegion(DataObject * output) override;
184 
186  virtual void
187  BeforeThreadedGenerateData();
188 
189  virtual void
190  ThreadedGenerateData(ThreadIdType threadId);
191 
193  virtual void
194  AfterThreadedGenerateData();
195 
197  void
198  GenerateData() override;
199 
201  ~BlockMatchingImageFilter() override = default;
202 
203  void
204  PrintSelf(std::ostream & os, Indent indent) const override;
205 
212  ThreaderCallback(void * arg);
213 
217  {
219  };
220 
221 private:
222  // algorithm parameters
223  ImageSizeType m_BlockRadius{};
224  ImageSizeType m_SearchRadius{};
225 
226  // temporary dynamic arrays for storing threads outputs
227  SizeValueType m_PointsCount{};
228  std::unique_ptr<DisplacementsVector[]> m_DisplacementsVectorsArray;
229  std::unique_ptr<SimilaritiesValue[]> m_SimilaritiesValuesArray;
230 };
231 } // end namespace itk
232 
233 #ifndef ITK_MANUAL_INSTANTIATION
234 # include "itkBlockMatchingImageFilter.hxx"
235 #endif
236 
237 #endif
itk::BlockMatchingImageFilter::FeaturePointsType
TFeatures FeaturePointsType
Definition: itkBlockMatchingImageFilter.h:102
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::BlockMatchingImageFilter::DisplacementsConstPointer
typename DisplacementsType::ConstPointer DisplacementsConstPointer
Definition: itkBlockMatchingImageFilter.h:110
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:68
itk::BlockMatchingImageFilter::m_DisplacementsVectorsArray
std::unique_ptr< DisplacementsVector[]> m_DisplacementsVectorsArray
Definition: itkBlockMatchingImageFilter.h:228
itk::Size< ImageDimension >
itk::BlockMatchingImageFilter::FeaturePointsPointer
typename FeaturePointsType::Pointer FeaturePointsPointer
Definition: itkBlockMatchingImageFilter.h:103
itk::ImageRegion
An image region represents a structured region of data.
Definition: itkImageRegion.h:80
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::ProcessObject::GetOutput
DataObject * GetOutput(const DataObjectIdentifierType &key)
itk::BlockMatchingImageFilter
Computes displacements of given points from a fixed image in a floating image.
Definition: itkBlockMatchingImageFilter.h:80
itkImage.h
itk::BlockMatchingImageFilter::m_SimilaritiesValuesArray
std::unique_ptr< SimilaritiesValue[]> m_SimilaritiesValuesArray
Definition: itkBlockMatchingImageFilter.h:229
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ProcessObject::DataObjectPointerArraySizeType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Definition: itkProcessObject.h:194
itk::BlockMatchingImageFilter::MovingImageConstPointer
typename MovingImageType::ConstPointer MovingImageConstPointer
Definition: itkBlockMatchingImageFilter.h:99
itk::BlockMatchingImageFilter::GetDisplacements
DisplacementsType * GetDisplacements()
Definition: itkBlockMatchingImageFilter.h:157
itk::BlockMatchingImageFilter::SimilaritiesValue
typename SimilaritiesType::PixelType SimilaritiesValue
Definition: itkBlockMatchingImageFilter.h:117
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itkDefaultDynamicMeshTraits.h
itk::ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
Definition: itkThreadSupport.h:79
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::BlockMatchingImageFilter::FixedImageConstPointer
typename FixedImageType::ConstPointer FixedImageConstPointer
Definition: itkBlockMatchingImageFilter.h:94
itk::BlockMatchingImageFilter::DisplacementsType
TDisplacements DisplacementsType
Definition: itkBlockMatchingImageFilter.h:108
itk::BlockMatchingImageFilter::DisplacementsVector
typename DisplacementsType::PixelType DisplacementsVector
Definition: itkBlockMatchingImageFilter.h:111
itk::MeshToMeshFilter
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
Definition: itkMeshToMeshFilter.h:47
itk::BlockMatchingImageFilter::MovingImageType
TMovingImage MovingImageType
Definition: itkBlockMatchingImageFilter.h:98
itk::BlockMatchingImageFilter::SimilaritiesPointer
typename SimilaritiesType::Pointer SimilaritiesPointer
Definition: itkBlockMatchingImageFilter.h:115
itk::BlockMatchingImageFilter::GetSimilarities
SimilaritiesType * GetSimilarities()
Definition: itkBlockMatchingImageFilter.h:163
itkMeshToMeshFilter.h
itk::BlockMatchingImageFilter::FixedImagePixelType
typename FixedImageType::PixelType FixedImagePixelType
Definition: itkBlockMatchingImageFilter.h:95
itk::BlockMatchingImageFilter::FixedImageType
TFixedImage FixedImageType
Definition: itkBlockMatchingImageFilter.h:93
itk::BlockMatchingImageFilter::SimilaritiesConstPointer
typename SimilaritiesType::ConstPointer SimilaritiesConstPointer
Definition: itkBlockMatchingImageFilter.h:116
itk::BlockMatchingImageFilter::FeaturePointsPhysicalCoordinates
typename FeaturePointsType::PointType FeaturePointsPhysicalCoordinates
Definition: itkBlockMatchingImageFilter.h:105
itk::BlockMatchingImageFilter::SimilaritiesType
TSimilarities SimilaritiesType
Definition: itkBlockMatchingImageFilter.h:114
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::BlockMatchingImageFilter::ThreadStruct
Definition: itkBlockMatchingImageFilter.h:216
itkVector.h
itkPointSet.h
itk::BlockMatchingImageFilter::DisplacementsPointer
typename DisplacementsType::Pointer DisplacementsPointer
Definition: itkBlockMatchingImageFilter.h:109
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itk::BlockMatchingImageFilter::ThreadStruct::Filter
Pointer Filter
Definition: itkBlockMatchingImageFilter.h:218
itk::BlockMatchingImageFilter::FeaturePointsConstPointer
typename FeaturePointsType::ConstPointer FeaturePointsConstPointer
Definition: itkBlockMatchingImageFilter.h:104