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 =========================================================================*/
32 #ifndef vtkImageDifference_h
33 #define vtkImageDifference_h
34 
35 #include "vtkImagingCoreModule.h" // For export macro
36 #include "vtkSmartPointer.h" // For smart pointer
38 
39 class vtkImageDifferenceThreadData;
40 class vtkImageDifferenceSMPThreadLocal;
41 
42 class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
43 {
44 public:
45  static vtkImageDifference* New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
50 
53  void SetImageConnection(vtkAlgorithmOutput* output) { this->SetInputConnection(1, output); }
54  void SetImageData(vtkDataObject* image) { this->SetInputData(1, image); }
55  vtkImageData* GetImage();
57 
61  double GetError() { return this->Error; }
62  void GetError(double* e) { *e = this->GetError(); }
63 
69  double GetThresholdedError() { return this->ThresholdedError; }
70  void GetThresholdedError(double* e) { *e = this->GetThresholdedError(); }
71 
73 
76  vtkSetMacro(Threshold, int);
77  vtkGetMacro(Threshold, int);
79 
81 
88  vtkSetMacro(AllowShift, bool);
89  vtkGetMacro(AllowShift, bool);
90  vtkBooleanMacro(AllowShift, bool);
92 
94 
100  vtkSetMacro(Averaging, bool);
101  vtkGetMacro(Averaging, bool);
102  vtkBooleanMacro(Averaging, bool);
104 
106 
110  vtkSetMacro(AverageThresholdFactor, double);
111  vtkGetMacro(AverageThresholdFactor, double);
113 
114 protected:
116  ~vtkImageDifference() override = default;
117 
118  // Parameters
119  // ideally threshold * averageThresholdFactor should be < 255/9
120  // to capture one pixel errors or 510/9 to capture 2 pixel errors
121  bool AllowShift = true;
122  bool Averaging = true;
123  int Threshold = 105;
124  double AverageThresholdFactor = 0.65;
125 
126  // Outputs
127  const char* ErrorMessage = nullptr;
128  double Error = 0.;
129  double ThresholdedError = 0.;
130 
134 
135  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
136  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
137  int outExt[6], int threadId) override;
138 
139  void GrowExtent(int* uExt, int* wholeExtent);
140  int ComputeSumedValue(unsigned char* values, vtkIdType* indices, int comp);
141 
142  // Used for vtkMultiThreader operation.
143  vtkImageDifferenceThreadData* ThreadData;
144 
145  // Used for vtkSMPTools operation.
146  vtkImageDifferenceSMPThreadLocal* SMPThreadData = nullptr;
147 
148 private:
149  vtkImageDifference(const vtkImageDifference&) = delete;
150  void operator=(const vtkImageDifference&) = delete;
151 
152  friend class vtkImageDifferenceSMPFunctor;
153 };
154 
155 #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:332
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:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
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:65