#include <itkStructuralSimilarityImageFilter.h>
Computes the (multi-scale) Structural Similarity Index Measure between two images.
This filter computes the Structural Similarity Index Measure (SSIM) [150] and its multi-scale extension (MS-SSIM) [149] between two input images of identical geometry. The output image stores the per-pixel SSIM map at the original resolution. The scalar SSIM, or MS-SSIM when there is more than one scale, is available via GetMSSSIM() after Update().
\[ l = \frac{2\mu_x\mu_y + C_1}{\mu_x^2 + \mu_y^2 + C_1}, \qquad cs = \frac{2\sigma_{xy} + C_2}{\sigma_x^2 + \sigma_y^2 + C_2}, \qquad \mathrm{ssim} = l \cdot cs, \]
with \(C_1 = (K_1 L)^2\), \(C_2 = (K_2 L)^2\) and \(L\) the dynamic range. If any ofLuminanceExponent ( \(\alpha\)), ContrastExponent ( \(\beta\)) or StructureExponent ( \(\gamma\)) differs from 1, \(cs = c^\beta s^\gamma\) and \(\mathrm{ssim} = l^\alpha c^\beta s^\gamma\) with the separate contrast and structure terms of [150] and \(C_3 = C_2/2\). In that case \(l\) and \(s\) are clamped at 0 before exponentiation, because a negative base with a fractional exponent is undefined; unlike the unit-exponent form, that map is non-negative.ScaleWeights), \[ \mathrm{MS\mbox{-}SSIM}(x,y) = \max(\overline{\mathrm{ssim}}_{M-1}, \epsilon)^{w_{M-1}} \prod_{j=0}^{M-2} \max(\overline{cs}_j, \epsilon)^{w_j}, \qquad \epsilon = \mathrm{MinimumScaleValue} = 10^{-6}. \]
The floor keeps the product finite and away from zero when a per-scale mean is not positive. The default weights are WangEtAl2003ScaleWeights(). With a single scale ( \(M = 1\)) the result is the plain, unfloored mean SSIM \(\overline{\mathrm{ssim}}_0\), which can be negative, and the weight value is not used. Weights must be finite and non-negative. Each image dimension must survive \(M-1\) BinShrinkImageFilter halvings, i.e. have at least \(2^{M-1}\) pixels (more when the region's start index is not a multiple of \(2^{M-1}\)).Eq. 7 of [149] can be read as exponentiating per-pixel terms. This filter follows the authors' reference MATLAB implementation (msssim.m) instead: each scale's map is pooled to its mean before the weights are applied, and the low-pass filter before subsampling is a 2x2 average. Results still differ slightly from msssim.m, which averages each map only over pixels whose window lies fully inside the image, while this filter averages over the whole image; msssim.m also does not floor the per-scale means at MinimumScaleValue.
The filter is N-dimensional and multi-threaded. The output pixel type defaults to float.
Definition at line 106 of file itkStructuralSimilarityImageFilter.h.
Inheritance diagram for itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >:
Collaboration diagram for itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >:Public Member Functions | |
| virtual::itk::LightObject::Pointer | CreateAnother () const |
| virtual double | GetMSSSIM () const |
| virtual const char * | GetNameOfClass () const |
| void | SetInput1 (const InputImageType *image) |
| const InputImageType * | GetInput1 () const |
| void | SetInput2 (const InputImageType *image) |
| const InputImageType * | GetInput2 () const |
| virtual void | SetGaussianSigma (double _arg) |
| virtual double | GetGaussianSigma () const |
| virtual void | SetK1 (double _arg) |
| virtual double | GetK1 () const |
| virtual void | SetK2 (double _arg) |
| virtual double | GetK2 () const |
| virtual void | SetDynamicRange (double _arg) |
| virtual double | GetDynamicRange () const |
| virtual void | SetLuminanceExponent (double _arg) |
| virtual double | GetLuminanceExponent () const |
| virtual void | SetContrastExponent (double _arg) |
| virtual double | GetContrastExponent () const |
| virtual void | SetStructureExponent (double _arg) |
| virtual double | GetStructureExponent () const |
| void | SetScaleWeights (const ScaleWeightsType &weights) |
| virtual const ScaleWeightsType & | GetScaleWeights () const |
| virtual const ScaleValuesType & | GetSSIMPerScale () const |
| virtual const ScaleValuesType & | GetContrastStructurePerScale () const |
Public Member Functions inherited from itk::ImageToImageFilter< TInputImage, TOutputImage > | |
| const InputImageType * | GetInput () const |
| const InputImageType * | GetInput (unsigned int idx) const |
| void | PopBackInput () override |
| void | PopFrontInput () override |
| virtual void | PushBackInput (const InputImageType *input) |
| virtual void | PushFrontInput (const InputImageType *input) |
| virtual void | SetInput (const InputImageType *input) |
| virtual void | SetInput (unsigned int, const TInputImage *image) |
| virtual void | SetCoordinateTolerance (double _arg) |
| virtual double | GetCoordinateTolerance () const |
| virtual void | SetDirectionTolerance (double _arg) |
| virtual double | GetDirectionTolerance () const |
Public Member Functions inherited from itk::ImageSource< TOutputImage > | |
| OutputImageType * | GetOutput (unsigned int idx) |
| virtual void | GraftNthOutput (unsigned int idx, DataObject *graft) |
| virtual void | GraftOutput (const DataObjectIdentifierType &key, DataObject *graft) |
| virtual void | GraftOutput (DataObject *graft) |
| OutputImageType * | GetOutput () |
| const OutputImageType * | GetOutput () const |
| ProcessObject::DataObjectPointer | MakeOutput (ProcessObject::DataObjectPointerArraySizeType idx) override |
| ProcessObject::DataObjectPointer | MakeOutput (const ProcessObject::DataObjectIdentifierType &) override |
Public Member Functions inherited from itk::ProcessObject | |
| virtual void | AbortGenerateDataOff () |
| virtual void | AbortGenerateDataOn () |
| virtual const bool & | GetAbortGenerateData () const |
| DataObjectPointerArray | GetIndexedInputs () |
| DataObjectPointerArray | GetIndexedOutputs () |
| NameArray | GetInputNames () const |
| DataObjectPointerArray | GetInputs () |
| MultiThreaderBase * | GetMultiThreader () const |
| DataObjectPointerArraySizeType | GetNumberOfIndexedInputs () const |
| DataObjectPointerArraySizeType | GetNumberOfIndexedOutputs () const |
| DataObjectPointerArraySizeType | GetNumberOfInputs () const |
| DataObjectPointerArraySizeType | GetNumberOfOutputs () const |
| virtual DataObjectPointerArraySizeType | GetNumberOfValidRequiredInputs () const |
| NameArray | GetOutputNames () const |
| DataObjectPointerArray | GetOutputs () |
| virtual float | GetProgress () const |
| NameArray | GetRequiredInputNames () const |
| bool | HasInput (const DataObjectIdentifierType &key) const |
| bool | HasOutput (const DataObjectIdentifierType &key) const |
| void | IncrementProgress (float increment) |
| virtual void | PrepareOutputs () |
| virtual void | PropagateRequestedRegion (DataObject *output) |
| virtual void | ResetPipeline () |
| virtual void | SetAbortGenerateData (bool _arg) |
| void | SetMultiThreader (MultiThreaderBase *threader) |
| virtual void | Update () |
| virtual void | UpdateLargestPossibleRegion () |
| virtual void | UpdateOutputData (DataObject *output) |
| virtual void | UpdateOutputInformation () |
| void | UpdateProgress (float progress) |
| virtual void | SetReleaseDataFlag (bool val) |
| virtual bool | GetReleaseDataFlag () const |
| void | ReleaseDataFlagOn () |
| void | ReleaseDataFlagOff () |
| virtual void | SetReleaseDataBeforeUpdateFlag (bool _arg) |
| virtual const bool & | GetReleaseDataBeforeUpdateFlag () const |
| virtual void | ReleaseDataBeforeUpdateFlagOn () |
| virtual void | ReleaseDataBeforeUpdateFlagOff () |
| itkVirtualSetClampMacro (NumberOfWorkUnits, ThreadIdType, 1, ITK_MAX_THREADS) | |
| virtual const ThreadIdType & | GetNumberOfWorkUnits () const |
Public Member Functions inherited from itk::Object | |
| unsigned long | AddObserver (const EventObject &event, Command *cmd) const |
| unsigned long | AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const |
| virtual void | DebugOff () const |
| virtual void | DebugOn () const |
| Command * | GetCommand (unsigned long tag) |
| bool | GetDebug () const |
| MetaDataDictionary & | GetMetaDataDictionary () |
| const MetaDataDictionary & | GetMetaDataDictionary () const |
| virtual ModifiedTimeType | GetMTime () const |
| virtual const TimeStamp & | GetTimeStamp () const |
| bool | HasObserver (const EventObject &event) const |
| void | InvokeEvent (const EventObject &) |
| void | InvokeEvent (const EventObject &) const |
| virtual void | Modified () const |
| void | Register () const override |
| void | RemoveAllObservers () |
| void | RemoveObserver (unsigned long tag) const |
| void | SetDebug (bool debugFlag) const |
| void | SetReferenceCount (int) override |
| void | UnRegister () const noexcept override |
| void | SetMetaDataDictionary (const MetaDataDictionary &rhs) |
| void | SetMetaDataDictionary (MetaDataDictionary &&rrhs) |
| virtual void | SetObjectName (std::string _arg) |
| virtual const std::string & | GetObjectName () const |
Public Member Functions inherited from itk::LightObject | |
| Pointer | Clone () const |
| virtual void | Delete () |
| virtual int | GetReferenceCount () const |
| void | Print (std::ostream &os, Indent indent=0) const |
Static Public Member Functions | |
| static ScaleWeightsType | GaussianScaleWeights (unsigned int size, double sigma) |
| static Pointer | New () |
| static ScaleWeightsType | WangEtAl2003ScaleWeights () |
Static Public Member Functions inherited from itk::ImageToImageFilter< TInputImage, TOutputImage > | |
| static double | GetGlobalDefaultCoordinateTolerance () |
| static double | GetGlobalDefaultDirectionTolerance () |
| static void | SetGlobalDefaultCoordinateTolerance (double) |
| static void | SetGlobalDefaultDirectionTolerance (double) |
Static Public Member Functions inherited from itk::Object | |
| static bool | GetGlobalWarningDisplay () |
| static void | GlobalWarningDisplayOff () |
| static void | GlobalWarningDisplayOn () |
| static Pointer | New () |
| static void | SetGlobalWarningDisplay (bool val) |
Static Public Member Functions inherited from itk::LightObject | |
| static void | BreakOnError () |
| static Pointer | New () |
Static Public Attributes | |
| static constexpr unsigned int | ImageDimension = InputImageType::ImageDimension |
| static constexpr RealType | MinimumScaleValue { 1e-6 } |
Static Public Attributes inherited from itk::ImageToImageFilter< TInputImage, TOutputImage > | |
| static constexpr unsigned int | InputImageDimension = TInputImage::ImageDimension |
| static constexpr unsigned int | OutputImageDimension = TOutputImage::ImageDimension |
Static Public Attributes inherited from itk::ImageSource< TOutputImage > | |
| static constexpr unsigned int | OutputImageDimension = TOutputImage::ImageDimension |
Static Private Member Functions | |
| static constexpr double | DefaultDynamicRange () |
Private Attributes | |
| double | m_ContrastExponent { 1.0 } |
| ScaleValuesType | m_ContrastStructurePerScale {} |
| double | m_DynamicRange { DefaultDynamicRange() } |
| double | m_GaussianSigma { 1.5 } |
| double | m_K1 { 0.01 } |
| double | m_K2 { 0.03 } |
| double | m_LuminanceExponent { 1.0 } |
| double | m_MSSSIM { 0.0 } |
| ScaleWeightsType | m_ScaleWeights { WangEtAl2003ScaleWeights() } |
| ScaleValuesType | m_SSIMPerScale {} |
| double | m_StructureExponent { 1.0 } |
Additional Inherited Members | |
Protected Types inherited from itk::ImageToImageFilter< TInputImage, TOutputImage > | |
| using | InputToOutputRegionCopierType |
| using | OutputToInputRegionCopierType |
Static Protected Member Functions inherited from itk::ImageSource< TOutputImage > | |
| static const ImageRegionSplitterBase * | GetGlobalDefaultSplitter () |
| static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION | ThreaderCallback (void *arg) |
Static Protected Member Functions inherited from itk::ProcessObject | |
| template<typename TSourceObject> | |
| static void | MakeRequiredOutputs (TSourceObject &sourceObject, const DataObjectPointerArraySizeType numberOfRequiredOutputs) |
| static constexpr float | progressFixedToFloat (uint32_t fixed) |
| static uint32_t | progressFloatToFixed (float f) |
Protected Attributes inherited from itk::ImageSource< TOutputImage > | |
| bool | m_DynamicMultiThreading { true } |
Protected Attributes inherited from itk::ProcessObject | |
| TimeStamp | m_OutputInformationMTime {} |
| bool | m_Updating {} |
Protected Attributes inherited from itk::LightObject | |
| std::atomic< int > | m_ReferenceCount {} |
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::ConstPointer = SmartPointer<const Self> |
Definition at line 115 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::IndexType = typename InputImageType::IndexType |
Definition at line 131 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::InputImageRegionType = typename InputImageType::RegionType |
Definition at line 128 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::InputImageType = TInputImage |
Image type aliases.
Definition at line 124 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::InputPixelType = typename InputImageType::PixelType |
Definition at line 126 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::OutputImageRegionType = typename OutputImageType::RegionType |
Definition at line 129 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::OutputImageType = TOutputImage |
Definition at line 125 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::OutputPixelType = typename OutputImageType::PixelType |
Definition at line 127 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::Pointer = SmartPointer<Self> |
Definition at line 114 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::RealType = typename NumericTraits<InputPixelType>::RealType |
Floating-point type used for all SSIM computations.
Definition at line 136 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::ScaleValuesType = Array<RealType> |
Definition at line 140 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::ScaleWeightsType = Array<RealType> |
Type used for the multi-scale weights and the per-scale results.
Definition at line 139 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::Self = StructuralSimilarityImageFilter |
Standard class type aliases.
Definition at line 112 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::SizeType = typename InputImageType::SizeType |
Definition at line 130 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::Superclass = ImageToImageFilter<TInputImage, TOutputImage> |
Definition at line 113 of file itkStructuralSimilarityImageFilter.h.
|
protected |
Referenced by GetNameOfClass().
|
overrideprotecteddefault |
|
virtual |
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.
Reimplemented from itk::Object.
|
inlinestaticconstexprprivate |
Default dynamic range: 1.0 for floating-point pixels (assume normalized data), and NumericTraits::max() - NumericTraits::min() for integer pixels (e.g. 255 for unsigned char).
Definition at line 278 of file itkStructuralSimilarityImageFilter.h.
References itk::NumericTraits< T >::max(), and itk::NumericTraits< T >::min().
|
overrideprotectedvirtual |
This filter computes the full output.
Reimplemented from itk::ProcessObject.
|
static |
Returns size samples of a Gaussian of standard deviation sigma, centered on the middle element and normalized to sum to 1. Throws if sigma is not finite and strictly positive.
|
overrideprotectedvirtual |
A version of GenerateData() specific for image processing filters. This implementation will split the processing across multiple threads. The buffer is allocated by this method. Then the BeforeThreadedGenerateData() method is called (if provided). Then, a series of threads are spawned each calling DynamicThreadedGenerateData(). After all the threads have completed processing, the AfterThreadedGenerateData() method is called (if provided). If an image processing filter cannot be threaded, the filter should provide an implementation of GenerateData(). That implementation is responsible for allocating the output buffer. If a filter can be threaded, it should NOT provide a GenerateData() method but should provide a DynamicThreadedGenerateData() instead.
Reimplemented from itk::ImageSource< TOutputImage >.
|
virtual |
Exponent \(\beta\) on the contrast term. Default 1.0.
|
virtual |
Per-scale means \(\overline{\mathrm{ssim}}_j\) and \(\overline{cs}_j\), finest scale first, before flooring. Available after Update().
|
virtual |
Dynamic range \(L\) of the pixel values used to compute \(C_1 = (K_1 L)^2\) and \(C_2 = (K_2 L)^2\). Default depends on the input pixel type: 255 for unsigned char, 65535 for unsigned short, 1.0 for float / double, etc.
|
virtual |
Standard deviation \(\sigma\) of the Gaussian window at the finest scale, in physical units. Default 1.5.
|
inline |
Set/Get the first input image.
Definition at line 150 of file itkStructuralSimilarityImageFilter.h.
References itk::ImageToImageFilter< TInputImage, TOutputImage >::GetInput().
| const InputImageType * itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::GetInput2 | ( | ) | const |
Set/Get the second input image.
|
virtual |
\(K_1\) stability constant. Default 0.01.
|
virtual |
\(K_2\) stability constant. Default 0.03.
|
virtual |
Exponent \(\alpha\) on the luminance term. Default 1.0.
|
virtual |
(MS-)SSIM. Available after Update(). With one scale it is the spatial mean of the output SSIM map, \(\overline{\mathrm{ssim}}_0\). With more scales it is not a mean but the MS-SSIM product of floored per-scale means given in the class documentation.
|
virtual |
Reimplemented from itk::ImageToImageFilter< TInputImage, TOutputImage >.
References StructuralSimilarityImageFilter().
|
virtual |
Per-scale exponents \(w_j\); the number of elements is the number of scales. A single element requests single-scale SSIM. Default WangEtAl2003ScaleWeights().
|
virtual |
Per-scale means \(\overline{\mathrm{ssim}}_j\) and \(\overline{cs}_j\), finest scale first, before flooring. Available after Update().
|
virtual |
Exponent \(\gamma\) on the structure term. Default 1.0.
|
static |
Method for creation through the object factory.
|
overrideprotectedvirtual |
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from itk::ImageToImageFilter< TInputImage, TOutputImage >.
|
virtual |
Exponent \(\beta\) on the contrast term. Default 1.0.
|
virtual |
Dynamic range \(L\) of the pixel values used to compute \(C_1 = (K_1 L)^2\) and \(C_2 = (K_2 L)^2\). Default depends on the input pixel type: 255 for unsigned char, 65535 for unsigned short, 1.0 for float / double, etc.
|
virtual |
Standard deviation \(\sigma\) of the Gaussian window at the finest scale, in physical units. Default 1.5.
|
inline |
Set/Get the first input image.
Definition at line 145 of file itkStructuralSimilarityImageFilter.h.
References itk::ImageToImageFilter< TInputImage, TOutputImage >::SetInput().
| void itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::SetInput2 | ( | const InputImageType * | image | ) |
Set/Get the second input image.
|
virtual |
\(K_1\) stability constant. Default 0.01.
|
virtual |
\(K_2\) stability constant. Default 0.03.
|
virtual |
Exponent \(\alpha\) on the luminance term. Default 1.0.
| void itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::SetScaleWeights | ( | const ScaleWeightsType & | weights | ) |
Per-scale exponents \(w_j\); the number of elements is the number of scales. A single element requests single-scale SSIM. Default WangEtAl2003ScaleWeights().
|
virtual |
Exponent \(\gamma\) on the structure term. Default 1.0.
|
overrideprotectedvirtual |
Verify that parameters are valid and both inputs are set with matching regions.
Reimplemented from itk::ProcessObject.
|
static |
Returns the 5-scale MS-SSIM weights of Wang et al. 2003 [149] \((0.0448,\ 0.2856,\ 0.3001,\ 0.2363,\ 0.1333)\).
|
staticconstexpr |
Definition at line 133 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 292 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 299 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 290 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 270 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 271 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 272 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 291 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 297 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 295 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 298 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 293 of file itkStructuralSimilarityImageFilter.h.
|
staticconstexpr |
Floor \(\epsilon\) applied to the per-scale means in the MS-SSIM product, keeping it finite and non-zero when a mean is not positive.
Definition at line 233 of file itkStructuralSimilarityImageFilter.h.