VTK  9.7.1
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 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkDoubleArray;
39 class vtkImageSSIMThreadData;
40 class vtkImageSSIMSMPThreadLocal;
41 class VTKIMAGINGCORE_EXPORT vtkImageSSIM : public vtkThreadedImageAlgorithm
42 {
43 public:
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 
60  void SetInputToLab();
61 
66  void SetInputToRGB();
67 
72  void SetInputToRGBA();
73 
78  void SetInputToGrayscale();
79 
84  void SetInputToAuto();
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 
122 protected:
123  vtkImageSSIM();
124  ~vtkImageSSIM() override = default;
125 
128 
130  void AllocateOutputData(
131  vtkImageData* output, vtkInformation* outInfo, VTK_FUTURE_CONST int uExtent[6]) override;
132 
133  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
134  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
135  VTK_FUTURE_CONST int outExt[6], int threadId) override;
136 
137  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
138  vtkInformationVector* outputVector) override;
139 
140 private:
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 
167 VTK_ABI_NAMESPACE_END
168 #endif
Store vtkAlgorithm input/output information.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
void SetImageConnection(vtkAlgorithmOutput *output)
Specify the Image to compare the input to.
Definition: vtkImageSSIM.h:52
void SetInputData(vtkDataObject *)
Assign a data object as input.
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
Proxy object to connect input/output ports.
dynamic, self-adjusting array of double
This filter implements an algorithm based on SSIM for image comparison.
Definition: vtkImageSSIM.h:41
Generic filter that has one input.
void SetImageData(vtkDataObject *image)
Specify the Image to compare the input to.
Definition: vtkImageSSIM.h:53
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void AllocateOutputData(vtkImageData *out, vtkInformation *outInfo, VTK_FUTURE_CONST int uExtent[6])
Allocate the output data.
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
virtual void ThreadedRequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector, vtkImageData ***inData, vtkImageData **outData, VTK_FUTURE_CONST int extent[6], int threadId)
If the subclass does not define an Execute method, then the task will be broken up, multiple threads will be spawned, and each thread will call this method.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
general representation of visualization data
Definition: vtkDataObject.h:55