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
39class vtkImageDifferenceThreadData;
40class vtkImageDifferenceSMPThreadLocal;
41
42class VTKIMAGINGCORE_EXPORT vtkImageDifference : public vtkThreadedImageAlgorithm
43{
44public:
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); }
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
114protected:
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
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
148private:
149 vtkImageDifference(const vtkImageDifference&) = delete;
150 void operator=(const vtkImageDifference&) = delete;
151
152 friend class vtkImageDifferenceSMPFunctor;
153};
154
155#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:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Generic filter that has one input.
int vtkIdType
Definition vtkType.h:332