ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSimilarityIndexImageFilter.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 itkSimilarityIndexImageFilter_h
19 #define itkSimilarityIndexImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkNumericTraits.h"
23 #include "itkArray.h"
24 
25 namespace itk
26 {
59 template< typename TInputImage1, typename TInputImage2 >
60 class ITK_TEMPLATE_EXPORT SimilarityIndexImageFilter:
61  public ImageToImageFilter< TInputImage1, TInputImage1 >
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_ASSIGN(SimilarityIndexImageFilter);
65 
71 
73  itkNewMacro(Self);
74 
77 
79  using InputImage1Type = TInputImage1;
80  using InputImage2Type = TInputImage2;
81  using InputImage1Pointer = typename TInputImage1::Pointer;
82  using InputImage2Pointer = typename TInputImage2::Pointer;
83  using InputImage1ConstPointer = typename TInputImage1::ConstPointer;
84  using InputImage2ConstPointer = typename TInputImage2::ConstPointer;
85 
87  using SizeType = typename TInputImage1::SizeType;
89 
90  using InputImage1PixelType = typename TInputImage1::PixelType;
91  using InputImage2PixelType = typename TInputImage2::PixelType;
92 
94  static constexpr unsigned int ImageDimension = TInputImage1::ImageDimension;
95 
98 
100  void SetInput1(const InputImage1Type *image)
101  { this->SetInput(image); }
102 
104  void SetInput2(const InputImage2Type *image);
105 
108  { return this->GetInput(); }
109 
111  const InputImage2Type * GetInput2();
112 
114  itkGetConstMacro(SimilarityIndex, RealType);
115 
116 #ifdef ITK_USE_CONCEPT_CHECKING
117  // Begin concept checking
118  itkConceptMacro( Input1HasNumericTraitsCheck,
120  itkConceptMacro( Input2HasNumericTraitsCheck,
122  // End concept checking
123 #endif
124 
125 protected:
127  ~SimilarityIndexImageFilter() override = default;
128  void PrintSelf(std::ostream & os, Indent indent) const override;
129 
132  void AllocateOutputs() override;
133 
135  void BeforeThreadedGenerateData() override;
136 
139  void AfterThreadedGenerateData() override;
140 
142  void ThreadedGenerateData(const RegionType &
143  outputRegionForThread,
144  ThreadIdType threadId) override;
145 
146  void DynamicThreadedGenerateData( const RegionType & ) override
147  {
148  itkExceptionMacro("This class requires threadId so it must use classic multi-threading model");
149  }
150 
151  // Override since the filter needs all the data for the algorithm
152  void GenerateInputRequestedRegion() override;
153 
154  // Override since the filter produces all of its output
155  void EnlargeOutputRequestedRegion(DataObject *data) override;
156 
157 private:
159 
163 }; // end of class
164 } // end namespace itk
165 
166 #ifndef ITK_MANUAL_INSTANTIATION
167 #include "itkSimilarityIndexImageFilter.hxx"
168 #endif
169 
170 #endif
typename TInputImage1::IndexType IndexType
Light weight base class for most itk classes.
Define numeric traits for std::vector.
void DynamicThreadedGenerateData(const RegionType &) override
typename TInputImage1::ConstPointer InputImage1ConstPointer
typename TInputImage1::PixelType InputImage1PixelType
typename TInputImage1::Pointer InputImage1Pointer
typename TInputImage1::RegionType RegionType
Measures the similarity between the set of non-zero pixels of two images.
void SetInput1(const InputImage1Type *image)
typename TInputImage2::ConstPointer InputImage2ConstPointer
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
typename TInputImage2::PixelType InputImage2PixelType
Base class for filters that take an image as input and produce an image as output.
typename NumericTraits< InputImage1PixelType >::RealType RealType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename TInputImage1::SizeType SizeType
typename TInputImage2::Pointer InputImage2Pointer
#define itkConceptMacro(name, concept)
Base class for all data objects in ITK.