VTK  9.6.20260613
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
26
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
131 vtkImageData* output, vtkInformation* outInfo, VTK_FUTURE_CONST int uExtent[6]) override;
132
134 vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
135 VTK_FUTURE_CONST int outExt[6], int threadId) override;
136
138 vtkInformationVector* outputVector) override;
139
140private:
141 void SetInputToAdditiveChar(unsigned int size);
142 void GrowExtent(int uExt[2], VTK_FUTURE_CONST int wholeExtent[2]);
143
144 int PatchRadius = 6;
145 bool ClampNegativeValues = false;
146
147 enum
148 {
149 MODE_LAB,
150 MODE_RGB,
151 MODE_RGBA,
152 MODE_GRAYSCALE,
153 MODE_AUTO,
154 MODE_INPUT_RANGE
155 };
156 int Mode = MODE_AUTO;
157
161 std::vector<std::array<double, 2>> C;
162
163 vtkImageSSIM(const vtkImageSSIM&) = delete;
164 void operator=(const vtkImageSSIM&) = delete;
165};
166
167VTK_ABI_NAMESPACE_END
168#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
dynamic, self-adjusting array of double
void SetInputData(vtkDataObject *)
Assign a data object as input.
virtual void AllocateOutputData(vtkImageData *out, vtkInformation *outInfo, VTK_FUTURE_CONST int uExtent[6])
Allocate the output data.
topologically and geometrically regular array of data
This filter implements an algorithm based on SSIM for image comparison.
void ThreadedRequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector, vtkImageData ***inData, vtkImageData **outData, VTK_FUTURE_CONST int outExt[6], int threadId) override
If the subclass does not define an Execute method, then the task will be broken up,...
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 AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, VTK_FUTURE_CONST int uExtent[6]) override
Allocate the output data.
void SetImageData(vtkDataObject *image)
Specify the Image to compare the input to.
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.
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.
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.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called in response to a REQUEST_DATA request from the executive.
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.