VTK  9.3.20240424
vtkImageDifference.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
39#ifndef vtkImageDifference_h
40#define vtkImageDifference_h
41
42#include "vtkImagingCoreModule.h" // For export macro
43#include "vtkSmartPointer.h" // For smart pointer
45
46VTK_ABI_NAMESPACE_BEGIN
47class vtkImageDifferenceThreadData;
48class vtkImageDifferenceSMPThreadLocal;
49
50class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
51{
52public:
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
58
61 void SetImageConnection(vtkAlgorithmOutput* output) { this->SetInputConnection(1, output); }
62 void SetImageData(vtkDataObject* image) { this->SetInputData(1, image); }
65
69 double GetError() { return this->Error; }
70 void GetError(double* e) { *e = this->GetError(); }
71
77 double GetThresholdedError() { return this->ThresholdedError; }
78 void GetThresholdedError(double* e) { *e = this->GetThresholdedError(); }
79
81
84 vtkSetMacro(Threshold, int);
85 vtkGetMacro(Threshold, int);
87
89
96 vtkSetMacro(AllowShift, bool);
97 vtkGetMacro(AllowShift, bool);
98 vtkBooleanMacro(AllowShift, bool);
100
102
108 vtkSetMacro(Averaging, bool);
109 vtkGetMacro(Averaging, bool);
110 vtkBooleanMacro(Averaging, bool);
112
114
118 vtkSetMacro(AverageThresholdFactor, double);
119 vtkGetMacro(AverageThresholdFactor, double);
121
122protected:
124 ~vtkImageDifference() override = default;
125
126 // Parameters
127 // ideally threshold * averageThresholdFactor should be < 255/9
128 // to capture one pixel errors or 510/9 to capture 2 pixel errors
129 bool AllowShift = true;
130 bool Averaging = true;
131 int Threshold = 105;
132 double AverageThresholdFactor = 0.65;
133
134 // Outputs
135 const char* ErrorMessage = nullptr;
136 double Error = 0.;
137 double ThresholdedError = 0.;
138
142
144 vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
145 int outExt[6], int threadId) override;
146
147 void GrowExtent(int* uExt, int* wholeExtent);
148 int ComputeSumedValue(unsigned char* values, vtkIdType* indices, int comp);
149
150 // Used for vtkMultiThreader operation.
151 vtkImageDifferenceThreadData* ThreadData;
152
153 // Used for vtkSMPTools operation.
154 vtkImageDifferenceSMPThreadLocal* SMPThreadData = nullptr;
155
156private:
157 vtkImageDifference(const vtkImageDifference&) = delete;
158 void operator=(const vtkImageDifference&) = delete;
159
160 friend class vtkImageDifferenceSMPFunctor;
161};
162
163VTK_ABI_NAMESPACE_END
164#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
void SetInputData(vtkDataObject *)
Assign a data object as input.
topologically and geometrically regular array of data
Compares images for regression tests.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int ComputeSumedValue(unsigned char *values, vtkIdType *indices, int comp)
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,...
void GetError(double *e)
void SetImageConnection(vtkAlgorithmOutput *output)
Specify the Image to compare the input to.
~vtkImageDifference() override=default
double GetThresholdedError()
Return the total thresholded error in comparing the two images.
static vtkImageDifference * New()
int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to translate the update extent requests from each output port ...
void GrowExtent(int *uExt, int *wholeExtent)
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkImageDifferenceThreadData * ThreadData
double GetError()
Return the total error in comparing the two images.
vtkImageData * GetImage()
Specify the Image to compare the input to.
void SetImageData(vtkDataObject *image)
Specify the Image to compare the input to.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
void GetThresholdedError(double *e)
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Generic filter that has one input.
int vtkIdType
Definition vtkType.h:315