VTK  9.2.6
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 =========================================================================*/
41 #ifndef vtkImageDifference_h
42 #define vtkImageDifference_h
43 
44 #include "vtkImagingCoreModule.h" // For export macro
45 #include "vtkSmartPointer.h" // For smart pointer
47 
48 class vtkImageDifferenceThreadData;
49 class vtkImageDifferenceSMPThreadLocal;
50 
51 class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
52 {
53 public:
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
59 
62  void SetImageConnection(vtkAlgorithmOutput* output) { this->SetInputConnection(1, output); }
63  void SetImageData(vtkDataObject* image) { this->SetInputData(1, image); }
66 
70  double GetError() { return this->Error; }
71  void GetError(double* e) { *e = this->GetError(); }
72 
78  double GetThresholdedError() { return this->ThresholdedError; }
79  void GetThresholdedError(double* e) { *e = this->GetThresholdedError(); }
80 
82 
85  vtkSetMacro(Threshold, int);
86  vtkGetMacro(Threshold, int);
88 
90 
97  vtkSetMacro(AllowShift, bool);
98  vtkGetMacro(AllowShift, bool);
99  vtkBooleanMacro(AllowShift, bool);
101 
103 
109  vtkSetMacro(Averaging, bool);
110  vtkGetMacro(Averaging, bool);
111  vtkBooleanMacro(Averaging, bool);
113 
115 
119  vtkSetMacro(AverageThresholdFactor, double);
120  vtkGetMacro(AverageThresholdFactor, double);
122 
123 protected:
125  ~vtkImageDifference() override = default;
126 
127  // Parameters
128  // ideally threshold * averageThresholdFactor should be < 255/9
129  // to capture one pixel errors or 510/9 to capture 2 pixel errors
130  bool AllowShift = true;
131  bool Averaging = true;
132  int Threshold = 105;
133  double AverageThresholdFactor = 0.65;
134 
135  // Outputs
136  const char* ErrorMessage = nullptr;
137  double Error = 0.;
138  double ThresholdedError = 0.;
139 
143 
145  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
146  int outExt[6], int threadId) override;
147 
148  void GrowExtent(int* uExt, int* wholeExtent);
149  int ComputeSumedValue(unsigned char* values, vtkIdType* indices, int comp);
150 
151  // Used for vtkMultiThreader operation.
152  vtkImageDifferenceThreadData* ThreadData;
153 
154  // Used for vtkSMPTools operation.
155  vtkImageDifferenceSMPThreadLocal* SMPThreadData = nullptr;
156 
157 private:
158  vtkImageDifference(const vtkImageDifference&) = delete;
159  void operator=(const vtkImageDifference&) = delete;
160 
161  friend class vtkImageDifferenceSMPFunctor;
162 };
163 
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
Definition: vtkDataObject.h:75
void SetInputData(vtkDataObject *)
Assign a data object as input.
topologically and geometrically regular array of data
Definition: vtkImageData.h:63
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:49
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