VTK  9.3.1
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 
27 VTK_ABI_NAMESPACE_BEGIN
28 class vtkImageDifferenceThreadData;
29 class vtkImageDifferenceSMPThreadLocal;
30 
31 class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
32 {
33 public:
34  static vtkImageDifference* New();
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); }
44  vtkImageData* GetImage();
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 
103 protected:
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 
124  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
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 
137 private:
138  vtkImageDifference(const vtkImageDifference&) = delete;
139  void operator=(const vtkImageDifference&) = delete;
140 
141  friend class vtkImageDifferenceSMPFunctor;
142 };
143 
144 VTK_ABI_NAMESPACE_END
145 #endif
void GetError(double *e)
Store vtkAlgorithm input/output information.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
Compares images for regression tests.
int vtkIdType
Definition: vtkType.h:315
void SetImageData(vtkDataObject *image)
Specify the Image to compare the input to.
void GetThresholdedError(double *e)
void SetInputData(vtkDataObject *)
Assign a data object as input.
double GetError()
Return the total error in comparing the two images.
void SetImageConnection(vtkAlgorithmOutput *output)
Specify the Image to compare the input to.
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.
Generic filter that has one input.
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
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, 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.
vtkImageDifferenceThreadData * ThreadData
double GetThresholdedError()
Return the total thresholded error in comparing the two images.
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:54