VTK  9.3.0
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
20#ifndef vtkImageDifference_h
21#define vtkImageDifference_h
22
23#include "vtkImagingCoreModule.h" // For export macro
24#include "vtkSmartPointer.h" // For smart pointer
26
27VTK_ABI_NAMESPACE_BEGIN
28class vtkImageDifferenceThreadData;
29class vtkImageDifferenceSMPThreadLocal;
30
31class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
32{
33public:
36 void PrintSelf(ostream& os, vtkIndent indent) override;
37
39
42 void SetImageConnection(vtkAlgorithmOutput* output) { this->SetInputConnection(1, output); }
43 void SetImageData(vtkDataObject* image) { this->SetInputData(1, image); }
46
50 double GetError() { return this->Error; }
51 void GetError(double* e) { *e = this->GetError(); }
52
58 double GetThresholdedError() { return this->ThresholdedError; }
59 void GetThresholdedError(double* e) { *e = this->GetThresholdedError(); }
60
62
65 vtkSetMacro(Threshold, int);
66 vtkGetMacro(Threshold, int);
68
70
77 vtkSetMacro(AllowShift, bool);
78 vtkGetMacro(AllowShift, bool);
79 vtkBooleanMacro(AllowShift, bool);
81
83
89 vtkSetMacro(Averaging, bool);
90 vtkGetMacro(Averaging, bool);
91 vtkBooleanMacro(Averaging, bool);
93
95
99 vtkSetMacro(AverageThresholdFactor, double);
100 vtkGetMacro(AverageThresholdFactor, double);
102
103protected:
105 ~vtkImageDifference() override = default;
106
107 // Parameters
108 // ideally threshold * averageThresholdFactor should be < 255/9
109 // to capture one pixel errors or 510/9 to capture 2 pixel errors
110 bool AllowShift = true;
111 bool Averaging = true;
112 int Threshold = 105;
113 double AverageThresholdFactor = 0.65;
114
115 // Outputs
116 const char* ErrorMessage = nullptr;
117 double Error = 0.;
118 double ThresholdedError = 0.;
119
123
125 vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
126 int outExt[6], int threadId) override;
127
128 void GrowExtent(int* uExt, int* wholeExtent);
129 int ComputeSumedValue(unsigned char* values, vtkIdType* indices, int comp);
130
131 // Used for vtkMultiThreader operation.
132 vtkImageDifferenceThreadData* ThreadData;
133
134 // Used for vtkSMPTools operation.
135 vtkImageDifferenceSMPThreadLocal* SMPThreadData = nullptr;
136
137private:
138 vtkImageDifference(const vtkImageDifference&) = delete;
139 void operator=(const vtkImageDifference&) = delete;
140
141 friend class vtkImageDifferenceSMPFunctor;
142};
143
144VTK_ABI_NAMESPACE_END
145#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:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Generic filter that has one input.
int vtkIdType
Definition vtkType.h:315