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
29 #ifndef vtkImageDifference_h
30 #define vtkImageDifference_h
31 
32 #include "vtkImagingCoreModule.h" // For export macro
33 #include "vtkSmartPointer.h" // For smart pointer
35 
36 VTK_ABI_NAMESPACE_BEGIN
37 class vtkImageDifferenceThreadData;
38 class vtkImageDifferenceSMPThreadLocal;
39 
40 class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
41 {
42 public:
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
48 
51  void SetImageConnection(vtkAlgorithmOutput* output) { this->SetInputConnection(1, output); }
52  void SetImageData(vtkDataObject* image) { this->SetInputData(1, image); }
55 
59  double GetError() { return this->Error; }
60  void GetError(double* e) { *e = this->GetError(); }
61 
67  double GetThresholdedError() { return this->ThresholdedError; }
68  void GetThresholdedError(double* e) { *e = this->GetThresholdedError(); }
69 
71 
74  vtkSetMacro(Threshold, int);
75  vtkGetMacro(Threshold, int);
77 
79 
86  vtkSetMacro(AllowShift, bool);
87  vtkGetMacro(AllowShift, bool);
88  vtkBooleanMacro(AllowShift, bool);
90 
92 
98  vtkSetMacro(Averaging, bool);
99  vtkGetMacro(Averaging, bool);
100  vtkBooleanMacro(Averaging, bool);
102 
104 
108  vtkSetMacro(AverageThresholdFactor, double);
109  vtkGetMacro(AverageThresholdFactor, double);
111 
112 protected:
114  ~vtkImageDifference() override = default;
115 
116  // Parameters
117  // ideally threshold * averageThresholdFactor should be < 255/9
118  // to capture one pixel errors or 510/9 to capture 2 pixel errors
119  bool AllowShift = true;
120  bool Averaging = true;
121  int Threshold = 105;
122  double AverageThresholdFactor = 0.65;
123 
124  // Outputs
125  const char* ErrorMessage = nullptr;
126  double Error = 0.;
127  double ThresholdedError = 0.;
128 
132 
134  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
135  int outExt[6], int threadId) override;
136 
137  void GrowExtent(int* uExt, int* wholeExtent);
138  int ComputeSumedValue(unsigned char* values, vtkIdType* indices, int comp);
139 
140  // Used for vtkMultiThreader operation.
141  vtkImageDifferenceThreadData* ThreadData;
142 
143  // Used for vtkSMPTools operation.
144  vtkImageDifferenceSMPThreadLocal* SMPThreadData = nullptr;
145 
146 private:
147  vtkImageDifference(const vtkImageDifference&) = delete;
148  void operator=(const vtkImageDifference&) = delete;
149 
150  friend class vtkImageDifferenceSMPFunctor;
151 };
152 
153 VTK_ABI_NAMESPACE_END
154 #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:64
void SetInputData(vtkDataObject *)
Assign a data object as input.
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
Compares images for regression tests.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkImageDifference * New()
int ComputeSumedValue(unsigned char *values, vtkIdType *indices, int comp)
vtkImageData * GetImage()
Specify the Image to compare the input to.
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.
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.
void SetImageData(vtkDataObject *image)
Specify the Image to compare the input to.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void GetThresholdedError(double *e)
a simple class to control print indentation
Definition: vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Generic filter that has one input.
@ image
Definition: vtkX3D.h:374
int vtkIdType
Definition: vtkType.h:315