VTK  9.5.2
vtkImageSSIM.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
27#ifndef vtkImageSSIM_h
28#define vtkImageSSIM_h
29
30#include "vtkImagingCoreModule.h" // For export macro
31#include "vtkSmartPointer.h" // For smart pointer
33
34#include <array>
35#include <vector>
36
37VTK_ABI_NAMESPACE_BEGIN
38class vtkDoubleArray;
39class vtkImageSSIMThreadData;
40class vtkImageSSIMSMPThreadLocal;
41class VTKIMAGINGCORE_EXPORT vtkImageSSIM : public vtkThreadedImageAlgorithm
42{
43public:
44 static vtkImageSSIM* New();
46 void PrintSelf(ostream& os, vtkIndent indent) override;
47
49
52 void SetImageConnection(vtkAlgorithmOutput* output) { this->SetInputConnection(1, output); }
53 void SetImageData(vtkDataObject* image) { this->SetInputData(1, image); }
55
61
67
73
79
85
92 void SetInputRange(std::vector<int>& range);
93
95
99 vtkSetMacro(ClampNegativeValues, bool);
100 vtkGetMacro(ClampNegativeValues, bool);
101 vtkBooleanMacro(ClampNegativeValues, bool);
103
105
110 vtkSetMacro(PatchRadius, double);
111 vtkGetMacro(PatchRadius, double);
113
120 static void ComputeErrorMetrics(vtkDoubleArray* scalars, double& tight, double& loose);
121
122protected:
124 ~vtkImageSSIM() override = default;
125
128
129 using Superclass::AllocateOutputData;
130 void AllocateOutputData(vtkImageData* output, vtkInformation* outInfo, int* uExtent) override;
131
133 vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
134 int outExt[6], int threadId) override;
135
137 vtkInformationVector* outputVector) override;
138
139private:
140 void SetInputToAdditiveChar(unsigned int size);
141 void GrowExtent(int* uExt, int* wholeExtent);
142
143 int PatchRadius = 6;
144 bool ClampNegativeValues = false;
145
146 enum
147 {
148 MODE_LAB,
149 MODE_RGB,
150 MODE_RGBA,
151 MODE_GRAYSCALE,
152 MODE_AUTO,
153 MODE_INPUT_RANGE
154 };
155 int Mode = MODE_AUTO;
156
160 std::vector<std::array<double, 2>> C;
161
162 vtkImageSSIM(const vtkImageSSIM&) = delete;
163 void operator=(const vtkImageSSIM&) = delete;
164};
165
166VTK_ABI_NAMESPACE_END
167#endif
Proxy object to connect input/output ports.
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
general representation of visualization data
Definition: vtkDataObject.h:56
dynamic, self-adjusting array of double
void SetInputData(vtkDataObject *)
Assign a data object as input.
topologically and geometrically regular array of data
Definition: vtkImageData.h:47
This filter implements an algorithm based on SSIM for image comparison.
Definition: vtkImageSSIM.h:42
void SetInputToAuto()
The c1 and c2 constant will be computed automatically based on the range of each individual component...
static void ComputeErrorMetrics(vtkDoubleArray *scalars, double &tight, double &loose)
Compute error metrics of a provided scalars.
void SetInputToRGB()
Assume the input is in RGB format, using integers from 0 to 255.
void SetImageData(vtkDataObject *image)
Specify the Image to compare the input to.
Definition: vtkImageSSIM.h:53
static vtkImageSSIM * New()
void SetInputToGrayscale()
Assume the input is in grayscale, using integers from 0 to 255.
void SetImageConnection(vtkAlgorithmOutput *output)
Specify the Image to compare the input to.
Definition: vtkImageSSIM.h:52
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetInputRange(std::vector< int > &range)
Setup the range of each components of the input scalars.
void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent) override
Allocate the output data.
int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to translate the update extent requests from each output port ...
~vtkImageSSIM() override=default
void SetInputToLab()
Assume the input is in Lab format.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetInputToRGBA()
Assume the input is in RGBA format, using integers from 0 to 255.
void ThreadedRequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector, vtkImageData ***inData, vtkImageData **outData, int outExt[6], int threadId) override
If the subclass does not define an Execute method, then the task will be broken up,...
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
a simple class to control print indentation
Definition: vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Generic filter that has one input.
@ range
Definition: vtkX3D.h:238
@ image
Definition: vtkX3D.h:374
@ size
Definition: vtkX3D.h:253