ITK  6.0.0
Insight Toolkit
itkMatchCardinalityImageToImageMetric.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 itkMatchCardinalityImageToImageMetric_h
19 #define itkMatchCardinalityImageToImageMetric_h
20 
26 #include "itkImageToImageMetric.h"
27 #include "itkPoint.h"
28 #include <vector>
29 
30 namespace itk
31 {
66 template <typename TFixedImage, typename TMovingImage>
67 class ITK_TEMPLATE_EXPORT MatchCardinalityImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>
68 {
69 public:
70  ITK_DISALLOW_COPY_AND_MOVE(MatchCardinalityImageToImageMetric);
71 
77 
79  itkNewMacro(Self);
80 
82  itkOverrideGetNameOfClassMacro(MatchCardinalityImageToImageMetric);
83 
85  using typename Superclass::RealType;
86  using typename Superclass::TransformType;
87  using typename Superclass::TransformPointer;
88  using typename Superclass::TransformParametersType;
89  using typename Superclass::TransformJacobianType;
90  using typename Superclass::GradientPixelType;
91 
92  using typename Superclass::MeasureType;
93  using typename Superclass::DerivativeType;
94  using typename Superclass::FixedImageType;
95  using typename Superclass::MovingImageType;
96  using typename Superclass::FixedImageConstPointer;
97  using typename Superclass::MovingImageConstPointer;
98  using typename Superclass::FixedImageRegionType;
99 
101  void
102  GetDerivative(const TransformParametersType &, DerivativeType & derivative) const override
103  {
104  itkWarningMacro("This metric does not provide metric derivatives.");
105  derivative.Fill(typename DerivativeType::ValueType{});
106  }
115  MeasureType
116  GetValue(const TransformParametersType & parameters) const override;
117 
124  itkSetMacro(MeasureMatches, bool);
125  itkBooleanMacro(MeasureMatches);
126  itkGetConstMacro(MeasureMatches, bool);
132  {
133  return m_Threader;
134  }
135 
136 protected:
138  ~MatchCardinalityImageToImageMetric() override = default;
139  void
140  PrintSelf(std::ostream & os, Indent indent) const override;
141 
147  MeasureType
148  GetNonconstValue(const TransformParametersType & parameters);
149 
154  virtual void
155  ThreadedGetValue(const FixedImageRegionType & regionForThread, ThreadIdType threadId);
156 
162  virtual ThreadIdType
163  SplitFixedRegion(ThreadIdType i, int num, FixedImageRegionType & splitRegion);
164 
172  ThreaderCallback(void * arg);
173 
177  {
179  };
180 
181 private:
182  // default to measure percentage of pixel matches
183  bool m_MeasureMatches{ true };
184  std::vector<MeasureType> m_ThreadMatches{};
185  std::vector<SizeValueType> m_ThreadCounts{};
186 
190 };
191 } // end namespace itk
194 #ifndef ITK_MANUAL_INSTANTIATION
195 # include "itkMatchCardinalityImageToImageMetric.hxx"
196 #endif
197 
198 #endif
itk::MultiThreaderBase
A class for performing multithreaded execution.
Definition: itkMultiThreaderBase.h:107
itk::ImageToImageMetric
Computes similarity between regions of two images.
Definition: itkImageToImageMetric.h:54
itk::MultiThreaderBase::New
static Pointer New()
itk::ImageToImageMetric::TransformParametersType
typename TransformType::ParametersType TransformParametersType
Definition: itkImageToImageMetric.h:92
itkPoint.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Array::Fill
void Fill(const TValue &v)
Definition: itkArray.h:114
itk::MatchCardinalityImageToImageMetric::GetDerivative
void GetDerivative(const TransformParametersType &, DerivativeType &derivative) const override
Definition: itkMatchCardinalityImageToImageMetric.h:102
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
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::MatchCardinalityImageToImageMetric::ThreadStruct
Definition: itkMatchCardinalityImageToImageMetric.h:176
itk::MatchCardinalityImageToImageMetric
Computes similarity between two objects to be registered.
Definition: itkMatchCardinalityImageToImageMetric.h:67
itkImageToImageMetric.h
itk::Array::ValueType
TValue ValueType
Definition: itkArray.h:52
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itk::MatchCardinalityImageToImageMetric::GetMultiThreader
MultiThreaderBase * GetMultiThreader()
Definition: itkMatchCardinalityImageToImageMetric.h:131
itk::MatchCardinalityImageToImageMetric::ThreadStruct::Metric
Pointer Metric
Definition: itkMatchCardinalityImageToImageMetric.h:178