ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkStructuralSimilarityImageFilter.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 itkStructuralSimilarityImageFilter_h
19#define itkStructuralSimilarityImageFilter_h
20
21#include "itkArray.h"
22#include "itkImage.h"
24#include "itkNumericTraits.h"
25
26#include <type_traits>
27
28namespace itk
29{
105template <typename TInputImage, typename TOutputImage = Image<float, TInputImage::ImageDimension>>
106class ITK_TEMPLATE_EXPORT StructuralSimilarityImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
107{
108public:
109 ITK_DISALLOW_COPY_AND_MOVE(StructuralSimilarityImageFilter);
110
116
118 itkNewMacro(Self);
119
121 itkOverrideGetNameOfClassMacro(StructuralSimilarityImageFilter);
122
124 using InputImageType = TInputImage;
125 using OutputImageType = TOutputImage;
126 using InputPixelType = typename InputImageType::PixelType;
127 using OutputPixelType = typename OutputImageType::PixelType;
128 using InputImageRegionType = typename InputImageType::RegionType;
129 using OutputImageRegionType = typename OutputImageType::RegionType;
130 using SizeType = typename InputImageType::SizeType;
131 using IndexType = typename InputImageType::IndexType;
132
133 static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
134
137
141
144 void
146 {
147 this->SetInput(image);
148 }
149 const InputImageType *
150 GetInput1() const
151 {
152 return this->GetInput(0);
153 }
154
155
158 void
159 SetInput2(const InputImageType * image);
160 const InputImageType *
161 GetInput2() const;
163
167 itkSetMacro(GaussianSigma, double);
168 itkGetConstMacro(GaussianSigma, double);
170
173 itkSetMacro(K1, double);
174 itkGetConstMacro(K1, double);
176
179 itkSetMacro(K2, double);
180 itkGetConstMacro(K2, double);
182
188 itkSetMacro(DynamicRange, double);
189 itkGetConstMacro(DynamicRange, double);
191
194 itkSetMacro(LuminanceExponent, double);
195 itkGetConstMacro(LuminanceExponent, double);
197
200 itkSetMacro(ContrastExponent, double);
201 itkGetConstMacro(ContrastExponent, double);
203
206 itkSetMacro(StructureExponent, double);
207 itkGetConstMacro(StructureExponent, double);
209
214 void
216 itkGetConstReferenceMacro(ScaleWeights, ScaleWeightsType);
218
222 static ScaleWeightsType
224
228 static ScaleWeightsType
229 GaussianScaleWeights(unsigned int size, double sigma);
230
233 static constexpr RealType MinimumScaleValue{ 1e-6 };
234
240 itkGetConstMacro(MSSSIM, double);
241
245 itkGetConstReferenceMacro(SSIMPerScale, ScaleValuesType);
246 itkGetConstReferenceMacro(ContrastStructurePerScale, ScaleValuesType);
248
249 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
250
251protected:
254
255 void
256 PrintSelf(std::ostream & os, Indent indent) const override;
257
259 void
260 VerifyPreconditions() const override;
261
263 void
265
266 void
267 GenerateData() override;
268
269private:
270 double m_GaussianSigma{ 1.5 };
271 double m_K1{ 0.01 };
272 double m_K2{ 0.03 };
273
277 static constexpr double
279 {
280 if constexpr (std::is_floating_point_v<InputPixelType>)
281 {
282 return 1.0;
283 }
284 else
285 {
286 return static_cast<double>(NumericTraits<InputPixelType>::max()) -
287 static_cast<double>(NumericTraits<InputPixelType>::min());
288 }
289 }
291 double m_LuminanceExponent{ 1.0 };
292 double m_ContrastExponent{ 1.0 };
293 double m_StructureExponent{ 1.0 };
294
296
297 double m_MSSSIM{ 0.0 };
300};
301} // end namespace itk
302
303#ifndef ITK_MANUAL_INSTANTIATION
304# include "itkStructuralSimilarityImageFilter.hxx"
305#endif
306
307#endif
Array class with size defined at construction time.
Definition itkArray.h:48
Base class for all data objects in ITK.
virtual void SetInput(const InputImageType *input)
const InputImageType * GetInput() const
Control indentation during Print() invocation.
Definition itkIndent.h:53
static constexpr T max(const T &)
static constexpr T min(const T &)
Implements transparent reference counting.
void EnlargeOutputRequestedRegion(DataObject *data) override
static ScaleWeightsType WangEtAl2003ScaleWeights()
~StructuralSimilarityImageFilter() override=default
typename InputImageType::RegionType InputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
ImageToImageFilter< TInputImage, TOutputImage > Superclass
void VerifyPreconditions() const override
void SetInput2(const InputImageType *image)
void SetScaleWeights(const ScaleWeightsType &weights)
void PrintSelf(std::ostream &os, Indent indent) const override
typename NumericTraits< InputPixelType >::RealType RealType
const InputImageType * GetInput2() const
static ScaleWeightsType GaussianScaleWeights(unsigned int size, double sigma)
typename OutputImageType::PixelType OutputPixelType
#define itkConceptMacro(name, conceptType)
Compile-time check that a template argument satisfies an itk::Concept.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....