#include <itkStructuralSimilarityImageFilter.h>
Computes the Structural Similarity Index Measure (SSIM) between two images.
This filter computes the Structural Similarity Index Measure [wang2004image] between two input images of identical geometry. The output image stores the per-pixel SSIM map. The scalar mean SSIM over the valid (non-boundary) region is available via GetMeanSSIM() after Update().
\[ \mu_x = G_\sigma * x, \quad \mu_y = G_\sigma * y, \]
\[ \sigma_x^2 = G_\sigma * x^2 - \mu_x^2,\quad \sigma_y^2 = G_\sigma * y^2 - \mu_y^2,\quad \sigma_{xy} = G_\sigma * (xy) - \mu_x \mu_y . \]
The three SSIM components are
\[ l(x,y) = \frac{2\mu_x\mu_y + C_1}{\mu_x^2 + \mu_y^2 + C_1}, \qquad c(x,y) = \frac{2\sigma_x\sigma_y + C_2}{\sigma_x^2 + \sigma_y^2 + C_2}, \qquad s(x,y) = \frac{\sigma_{xy} + C_3}{\sigma_x\sigma_y + C_3} \]
with \(C_1 = (K_1 L)^2\), \(C_2 = (K_2 L)^2\), \(C_3 = C_2/2\), and \(L\) the dynamic range of the pixel values.
The combined SSIM is
\[ \mathrm{SSIM}(x,y) = [l(x,y)]^{\alpha}\,[c(x,y)]^{\beta}\,[s(x,y)]^{\gamma}. \]
With the default exponents \(\alpha = \beta = \gamma = 1\) and the convention \(C_3 = C_2/2\), this collapses to the simplified form
\[ \mathrm{SSIM}(x,y) = \frac{(2\mu_x\mu_y + C_1)\,(2\sigma_{xy} + C_2)} {(\mu_x^2 + \mu_y^2 + C_1)\,(\sigma_x^2 + \sigma_y^2 + C_2)} \]
which matches the reference implementation distributed by Wang et al. and the default behavior of skimage.metrics.structural_similarity .
GaussianSigma: standard deviation of the Gaussian window (default 1.5, matching Wang et al.).MaximumKernelWidth: hard limit on the discrete Gaussian kernel width (default 11, matching the canonical 11x11 window).K1, K2: stability constants (defaults 0.01 and 0.03).DynamicRange: \(L\) in the formulas above; defaults to the dynamic range of the input pixel type via NumericTraits (e.g. 255 for unsigned char, 1.0 for float / double). For arbitrary floating-point images, set this explicitly to the actual data range.LuminanceExponent ( \(\alpha\)), ContrastExponent ( \(\beta\)), StructureExponent ( \(\gamma\)): defaults all 1.0.ScaleWeights: array of per-scale weights for multi-scale SSIM (MS-SSIM, [wang2003multiscale]). When the array contains a single element (the default), the filter computes ordinary single-scale SSIM. Multi-scale evaluation with more than one scale is not yet implemented and will raise an exception in BeforeGenerate.The filter is N-dimensional, multi-threaded, and templated over the input and output image types. The output pixel type defaults to float.
Definition at line 112 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 | GetMeanSSIM () 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 | SetMaximumKernelWidth (unsigned int _arg) |
| virtual unsigned int | GetMaximumKernelWidth () 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 |
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 () |
| virtual void | SetNumberOfWorkUnits (ThreadIdType _arg) |
| 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 Pointer | New () |
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 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 } |
| double | m_DynamicRange { DefaultDynamicRange() } |
| double | m_GaussianSigma { 1.5 } |
| double | m_K1 { 0.01 } |
| double | m_K2 { 0.03 } |
| double | m_LuminanceExponent { 1.0 } |
| unsigned int | m_MaximumKernelWidth { 11 } |
| double | m_MeanSSIM { 0.0 } |
| ScaleWeightsType | m_ScaleWeights { 1, static_cast<RealType>(1.0) } |
| 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 121 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::IndexType = typename InputImageType::IndexType |
Definition at line 137 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::InputImageRegionType = typename InputImageType::RegionType |
Definition at line 134 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::InputImageType = TInputImage |
Image type aliases.
Definition at line 130 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::InputPixelType = typename InputImageType::PixelType |
Definition at line 132 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::OutputImageRegionType = typename OutputImageType::RegionType |
Definition at line 135 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::OutputImageType = TOutputImage |
Definition at line 131 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::OutputPixelType = typename OutputImageType::PixelType |
Definition at line 133 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::Pointer = SmartPointer<Self> |
Definition at line 120 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 142 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::ScaleWeightsType = Array<RealType> |
Type used for the user-specified array of multi-scale weights.
Definition at line 145 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::Self = StructuralSimilarityImageFilter |
Standard class type aliases.
Definition at line 118 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::SizeType = typename InputImageType::SizeType |
Definition at line 136 of file itkStructuralSimilarityImageFilter.h.
| using itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::Superclass = ImageToImageFilter<TInputImage, TOutputImage> |
Definition at line 119 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 268 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.
|
overrideprotectedvirtual |
Composite-filter-style: drives the internal sub-pipeline (5 Gaussian convolutions plus a parallelized SSIM combination).
Reimplemented from itk::ImageSource< 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 used to compute local statistics. Default 1.5 (matching Wang et al. 2004).
|
inline |
Set/Get the first input image.
Definition at line 155 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 |
Maximum width (per dimension) of the discrete Gaussian kernel. Default 11, giving an 11x11 window in 2D when sigma=1.5.
|
virtual |
Mean SSIM over the valid (non-Gaussian-padded) region. Available after Update().
|
virtual |
Reimplemented from itk::ImageToImageFilter< TInputImage, TOutputImage >.
References StructuralSimilarityImageFilter().
|
virtual |
Per-scale weights for multi-scale SSIM (MS-SSIM). An array of size 1 (the default) requests ordinary single-scale SSIM and is the only configuration currently supported. Setting an array of length greater than 1 will currently raise an exception in BeforeGenerate.
|
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 used to compute local statistics. Default 1.5 (matching Wang et al. 2004).
|
inline |
Set/Get the first input image.
Definition at line 150 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.
|
virtual |
Maximum width (per dimension) of the discrete Gaussian kernel. Default 11, giving an 11x11 window in 2D when sigma=1.5.
| void itk::StructuralSimilarityImageFilter< TInputImage, TOutputImage >::SetScaleWeights | ( | const ScaleWeightsType & | weights | ) |
Per-scale weights for multi-scale SSIM (MS-SSIM). An array of size 1 (the default) requests ordinary single-scale SSIM and is the only configuration currently supported. Setting an array of length greater than 1 will currently raise an exception in BeforeGenerate.
|
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.
|
staticconstexpr |
Definition at line 139 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 282 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 280 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 259 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 261 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 262 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 281 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 260 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 287 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 285 of file itkStructuralSimilarityImageFilter.h.
|
private |
Definition at line 283 of file itkStructuralSimilarityImageFilter.h.