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=========================================================================*/
29#ifndef vtkImageDifference_h
30#define vtkImageDifference_h
31
32#include "vtkImagingCoreModule.h" // For export macro
33#include "vtkSmartPointer.h" // For smart pointer
35
36class vtkImageDifferenceThreadData;
37class vtkImageDifferenceSMPThreadLocal;
38
39class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
40{
41public:
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47
50 void SetImageConnection(vtkAlgorithmOutput* output) { this->SetInputConnection(1, output); }
51 void SetImageData(vtkDataObject* image) { this->SetInputData(1, image); }
54
58 double GetError() { return this->Error; }
59 void GetError(double* e) { *e = this->GetError(); }
60
66 double GetThresholdedError() { return this->ThresholdedError; }
67 void GetThresholdedError(double* e) { *e = this->GetThresholdedError(); }
68
70
73 vtkSetMacro(Threshold, int);
74 vtkGetMacro(Threshold, int);
76
78
85 vtkSetMacro(AllowShift, bool);
86 vtkGetMacro(AllowShift, bool);
87 vtkBooleanMacro(AllowShift, bool);
89
91
97 vtkSetMacro(Averaging, bool);
98 vtkGetMacro(Averaging, bool);
99 vtkBooleanMacro(Averaging, bool);
101
103
107 vtkSetMacro(AverageThresholdFactor, double);
108 vtkGetMacro(AverageThresholdFactor, double);
110
111protected:
113 ~vtkImageDifference() override = default;
114
115 // Parameters
116 // ideally threshold * averageThresholdFactor should be < 255/9
117 // to capture one pixel errors or 510/9 to capture 2 pixel errors
118 bool AllowShift = true;
119 bool Averaging = true;
120 int Threshold = 105;
121 double AverageThresholdFactor = 0.65;
122
123 // Outputs
124 const char* ErrorMessage = nullptr;
125 double Error = 0.;
126 double ThresholdedError = 0.;
127
131
133 vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
134 int outExt[6], int threadId) override;
135
136 void GrowExtent(int* uExt, int* wholeExtent);
137 int ComputeSumedValue(unsigned char* values, vtkIdType* indices, int comp);
138
139 // Used for vtkMultiThreader operation.
140 vtkImageDifferenceThreadData* ThreadData;
141
142 // Used for vtkSMPTools operation.
143 vtkImageDifferenceSMPThreadLocal* SMPThreadData = nullptr;
144
145private:
146 vtkImageDifference(const vtkImageDifference&) = delete;
147 void operator=(const vtkImageDifference&) = delete;
148
149 friend class vtkImageDifferenceSMPFunctor;
150};
151
152#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
Compares images for regression tests.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int ComputeSumedValue(unsigned char *values, vtkIdType *indices, int comp)
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.
static vtkImageDifference * New()
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.
vtkImageData * GetImage()
Specify the Image to compare the input to.
void SetImageData(vtkDataObject *image)
Specify the Image to compare the input to.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
void GetThresholdedError(double *e)
a simple class to control print indentation
Definition vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Generic filter that has one input.
int vtkIdType
Definition vtkType.h:332