VTK  9.2.5
vtkImageDifference.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageDifference.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
51 #ifndef vtkImageDifference_h
52 #define vtkImageDifference_h
53 
54 #include "vtkImagingCoreModule.h" // For export macro
55 #include "vtkSmartPointer.h" // For smart pointer
57 
58 class vtkImageDifferenceThreadData;
59 class vtkImageDifferenceSMPThreadLocal;
60 
61 class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
62 {
63 public:
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
69 
72  void SetImageConnection(vtkAlgorithmOutput* output) { this->SetInputConnection(1, output); }
73  void SetImageData(vtkDataObject* image) { this->SetInputData(1, image); }
76 
80  double GetError() { return this->Error; }
81  void GetError(double* e) { *e = this->GetError(); }
82 
88  double GetThresholdedError() { return this->ThresholdedError; }
89  void GetThresholdedError(double* e) { *e = this->GetThresholdedError(); }
90 
92 
95  vtkSetMacro(Threshold, int);
96  vtkGetMacro(Threshold, int);
98 
100 
107  vtkSetMacro(AllowShift, bool);
108  vtkGetMacro(AllowShift, bool);
109  vtkBooleanMacro(AllowShift, bool);
111 
113 
119  vtkSetMacro(Averaging, bool);
120  vtkGetMacro(Averaging, bool);
121  vtkBooleanMacro(Averaging, bool);
123 
125 
129  vtkSetMacro(AverageThresholdFactor, double);
130  vtkGetMacro(AverageThresholdFactor, double);
132 
133 protected:
135  ~vtkImageDifference() override = default;
136 
137  // Parameters
138  // ideally threshold * averageThresholdFactor should be < 255/9
139  // to capture one pixel errors or 510/9 to capture 2 pixel errors
140  bool AllowShift = true;
141  bool Averaging = true;
142  int Threshold = 105;
143  double AverageThresholdFactor = 0.65;
144 
145  // Outputs
146  const char* ErrorMessage = nullptr;
147  double Error = 0.;
148  double ThresholdedError = 0.;
149 
153 
155  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
156  int outExt[6], int threadId) override;
157 
158  void GrowExtent(int* uExt, int* wholeExtent);
159  int ComputeSumedValue(unsigned char* values, vtkIdType* indices, int comp);
160 
161  // Used for vtkMultiThreader operation.
162  vtkImageDifferenceThreadData* ThreadData;
163 
164  // Used for vtkSMPTools operation.
165  vtkImageDifferenceSMPThreadLocal* SMPThreadData = nullptr;
166 
167 private:
168  vtkImageDifference(const vtkImageDifference&) = delete;
169  void operator=(const vtkImageDifference&) = delete;
170 
171  friend class vtkImageDifferenceSMPFunctor;
172 };
173 
174 #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
Definition: vtkImageData.h:163
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:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Generic filter that has one input.
@ image
Definition: vtkX3D.h:380
int vtkIdType
Definition: vtkType.h:332