VTK
vtkImageMathematics.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageMathematics.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 =========================================================================*/
28 #ifndef vtkImageMathematics_h
29 #define vtkImageMathematics_h
30 
31 
32 // Operation options.
33 #define VTK_ADD 0
34 #define VTK_SUBTRACT 1
35 #define VTK_MULTIPLY 2
36 #define VTK_DIVIDE 3
37 #define VTK_INVERT 4
38 #define VTK_SIN 5
39 #define VTK_COS 6
40 #define VTK_EXP 7
41 #define VTK_LOG 8
42 #define VTK_ABS 9
43 #define VTK_SQR 10
44 #define VTK_SQRT 11
45 #define VTK_MIN 12
46 #define VTK_MAX 13
47 #define VTK_ATAN 14
48 #define VTK_ATAN2 15
49 #define VTK_MULTIPLYBYK 16
50 #define VTK_ADDC 17
51 #define VTK_CONJUGATE 18
52 #define VTK_COMPLEX_MULTIPLY 19
53 #define VTK_REPLACECBYK 20
54 
55 #include "vtkImagingMathModule.h" // For export macro
57 
58 class VTKIMAGINGMATH_EXPORT vtkImageMathematics : public vtkThreadedImageAlgorithm
59 {
60 public:
61  static vtkImageMathematics *New();
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
66 
69  vtkSetMacro(Operation,int);
70  vtkGetMacro(Operation,int);
72 
77  void SetOperationToAdd() {this->SetOperation(VTK_ADD);};
78 
83  void SetOperationToSubtract() {this->SetOperation(VTK_SUBTRACT);};
84 
89  void SetOperationToMultiply() {this->SetOperation(VTK_MULTIPLY);};
90 
95  void SetOperationToDivide() {this->SetOperation(VTK_DIVIDE);};
96 
97  void SetOperationToConjugate() {this->SetOperation(VTK_CONJUGATE);};
98 
100  {this->SetOperation(VTK_COMPLEX_MULTIPLY);};
101 
106  void SetOperationToInvert() {this->SetOperation(VTK_INVERT);};
107 
112  void SetOperationToSin() {this->SetOperation(VTK_SIN);};
113 
118  void SetOperationToCos() {this->SetOperation(VTK_COS);};
119 
124  void SetOperationToExp() {this->SetOperation(VTK_EXP);};
125 
130  void SetOperationToLog() {this->SetOperation(VTK_LOG);};
131 
136  void SetOperationToAbsoluteValue() {this->SetOperation(VTK_ABS);};
137 
142  void SetOperationToSquare() {this->SetOperation(VTK_SQR);};
143 
148  void SetOperationToSquareRoot() {this->SetOperation(VTK_SQRT);};
149 
154  void SetOperationToMin() {this->SetOperation(VTK_MIN);};
155 
160  void SetOperationToMax() {this->SetOperation(VTK_MAX);};
161 
166  void SetOperationToATAN() {this->SetOperation(VTK_ATAN);};
167 
168  void SetOperationToATAN2() {this->SetOperation(VTK_ATAN2);};
169 
174  void SetOperationToMultiplyByK() {this->SetOperation(VTK_MULTIPLYBYK);};
175 
180  void SetOperationToAddConstant() {this->SetOperation(VTK_ADDC);};
181 
186  void SetOperationToReplaceCByK() {this->SetOperation(VTK_REPLACECBYK);};
187 
189 
192  vtkSetMacro(ConstantK,double);
193  vtkGetMacro(ConstantK,double);
195 
197 
200  vtkSetMacro(ConstantC,double);
201  vtkGetMacro(ConstantC,double);
203 
205 
208  vtkSetMacro(DivideByZeroToC,vtkTypeBool);
209  vtkGetMacro(DivideByZeroToC,vtkTypeBool);
210  vtkBooleanMacro(DivideByZeroToC,vtkTypeBool);
212 
217  virtual void SetInput1Data(vtkDataObject *in) { this->SetInputData(0,in); }
218  virtual void SetInput2Data(vtkDataObject *in) { this->SetInputData(1,in); }
219 
220 protected:
222  ~vtkImageMathematics() override {}
223 
225  double ConstantK;
226  double ConstantC;
228 
231  vtkInformationVector *) override;
232 
233  void ThreadedRequestData(vtkInformation *request,
234  vtkInformationVector **inputVector,
235  vtkInformationVector *outputVector,
236  vtkImageData ***inData,
237  vtkImageData **outData,
238  int extent[6], int threadId) override;
239 
240  int FillInputPortInformation(int port, vtkInformation* info) override;
241 
242 private:
243  vtkImageMathematics(const vtkImageMathematics&) = delete;
244  void operator=(const vtkImageMathematics&) = delete;
245 };
246 
247 #endif
248 
vtkThreadedImageAlgorithm::ThreadedRequestData
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,...
vtkImageMathematics::SetOperationToSubtract
void SetOperationToSubtract()
Set each pixel in the output image to the difference of the corresponding pixels in Input1 and Input2...
Definition: vtkImageMathematics.h:83
VTK_COS
#define VTK_COS
Definition: vtkImageMathematics.h:39
VTK_SQRT
#define VTK_SQRT
Definition: vtkImageMathematics.h:44
vtkImageMathematics::SetOperationToAddConstant
void SetOperationToAddConstant()
Set each pixel in the output image to the product of ConstantC with the corresponding pixel in Input1...
Definition: vtkImageMathematics.h:180
vtkImageMathematics::SetOperationToMin
void SetOperationToMin()
Set each pixel in the output image to the minimum of the corresponding pixels in Input1 and Input2.
Definition: vtkImageMathematics.h:154
VTK_ADDC
#define VTK_ADDC
Definition: vtkImageMathematics.h:50
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkImageMathematics::Operation
int Operation
Definition: vtkImageMathematics.h:224
vtkImageMathematics::SetOperationToInvert
void SetOperationToInvert()
Set each pixel in the output image to 1 over the corresponding pixel in Input1 and Input2 (output = 1...
Definition: vtkImageMathematics.h:106
vtkThreadedImageAlgorithm
Generic filter that has one input.
Definition: vtkThreadedImageAlgorithm.h:43
vtkImageMathematics
Add, subtract, multiply, divide, invert, sin, cos, exp, log.
Definition: vtkImageMathematics.h:58
vtkImageMathematics::SetOperationToLog
void SetOperationToLog()
Set each pixel in the output image to the log of the corresponding pixel in Input1.
Definition: vtkImageMathematics.h:130
vtkImageMathematics::SetOperationToMax
void SetOperationToMax()
Set each pixel in the output image to the maximum of the corresponding pixels in Input1 and Input2.
Definition: vtkImageMathematics.h:160
vtkImageMathematics::SetOperationToExp
void SetOperationToExp()
Set each pixel in the output image to the exponential of the corresponding pixel in Input1.
Definition: vtkImageMathematics.h:124
VTK_ADD
#define VTK_ADD
Definition: vtkImageMathematics.h:33
VTK_MULTIPLY
#define VTK_MULTIPLY
Definition: vtkImageMathematics.h:35
vtkThreadedImageAlgorithm.h
VTK_MAX
#define VTK_MAX
Definition: vtkImageMathematics.h:46
vtkImageAlgorithm::SetInputData
void SetInputData(vtkDataObject *)
Assign a data object as input.
VTK_ABS
#define VTK_ABS
Definition: vtkImageMathematics.h:42
vtkX3D::port
Definition: vtkX3D.h:447
vtkImageMathematics::SetOperationToAdd
void SetOperationToAdd()
Set each pixel in the output image to the sum of the corresponding pixels in Input1 and Input2.
Definition: vtkImageMathematics.h:77
vtkImageMathematics::DivideByZeroToC
vtkTypeBool DivideByZeroToC
Definition: vtkImageMathematics.h:227
VTK_MULTIPLYBYK
#define VTK_MULTIPLYBYK
Definition: vtkImageMathematics.h:49
vtkImageMathematics::SetOperationToSquare
void SetOperationToSquare()
Set each pixel in the output image to the square of the corresponding pixel in Input1.
Definition: vtkImageMathematics.h:142
vtkImageAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
VTK_DIVIDE
#define VTK_DIVIDE
Definition: vtkImageMathematics.h:36
VTK_INVERT
#define VTK_INVERT
Definition: vtkImageMathematics.h:37
VTK_SUBTRACT
#define VTK_SUBTRACT
Definition: vtkImageMathematics.h:34
vtkThreadedImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VTK_CONJUGATE
#define VTK_CONJUGATE
Definition: vtkImageMathematics.h:51
VTK_ATAN
#define VTK_ATAN
Definition: vtkImageMathematics.h:47
vtkImageMathematics::SetOperationToDivide
void SetOperationToDivide()
Set each pixel in the output image to the quotient of the corresponding pixels in Input1 and Input2 (...
Definition: vtkImageMathematics.h:95
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkImageMathematics::SetOperationToMultiply
void SetOperationToMultiply()
Set each pixel in the output image to the product of the corresponding pixels in Input1 and Input2.
Definition: vtkImageMathematics.h:89
vtkImageMathematics::SetOperationToComplexMultiply
void SetOperationToComplexMultiply()
Definition: vtkImageMathematics.h:99
vtkImageMathematics::SetOperationToSin
void SetOperationToSin()
Set each pixel in the output image to the sine of the corresponding pixel in Input1.
Definition: vtkImageMathematics.h:112
vtkImageMathematics::SetOperationToCos
void SetOperationToCos()
Set each pixel in the output image to the cosine of the corresponding pixel in Input1.
Definition: vtkImageMathematics.h:118
vtkImageMathematics::SetInput2Data
virtual void SetInput2Data(vtkDataObject *in)
Definition: vtkImageMathematics.h:218
vtkImageMathematics::ConstantC
double ConstantC
Definition: vtkImageMathematics.h:226
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkX3D::info
Definition: vtkX3D.h:376
vtkAlgorithm::New
static vtkAlgorithm * New()
VTK_REPLACECBYK
#define VTK_REPLACECBYK
Definition: vtkImageMathematics.h:53
VTK_MIN
#define VTK_MIN
Definition: vtkImageMathematics.h:45
VTK_ATAN2
#define VTK_ATAN2
Definition: vtkImageMathematics.h:48
vtkImageMathematics::SetOperationToATAN
void SetOperationToATAN()
Set each pixel in the output image to the arctangent of the corresponding pixel in Input1.
Definition: vtkImageMathematics.h:166
VTK_COMPLEX_MULTIPLY
#define VTK_COMPLEX_MULTIPLY
Definition: vtkImageMathematics.h:52
vtkImageMathematics::SetOperationToSquareRoot
void SetOperationToSquareRoot()
Set each pixel in the output image to the square root of the corresponding pixel in Input1.
Definition: vtkImageMathematics.h:148
vtkImageMathematics::SetInput1Data
virtual void SetInput1Data(vtkDataObject *in)
Set the two inputs to this filter.
Definition: vtkImageMathematics.h:217
vtkImageMathematics::SetOperationToATAN2
void SetOperationToATAN2()
Definition: vtkImageMathematics.h:168
vtkImageMathematics::SetOperationToReplaceCByK
void SetOperationToReplaceCByK()
Find every pixel in Input1 that equals ConstantC and set the corresponding pixels in the Output to Co...
Definition: vtkImageMathematics.h:186
vtkX3D::extent
Definition: vtkX3D.h:345
VTK_LOG
#define VTK_LOG
Definition: vtkImageMathematics.h:41
VTK_EXP
#define VTK_EXP
Definition: vtkImageMathematics.h:40
vtkImageAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkImageMathematics::SetOperationToAbsoluteValue
void SetOperationToAbsoluteValue()
Set each pixel in the output image to the absolute value of the corresponding pixel in Input1.
Definition: vtkImageMathematics.h:136
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkImageMathematics::~vtkImageMathematics
~vtkImageMathematics() override
Definition: vtkImageMathematics.h:222
vtkImageMathematics::ConstantK
double ConstantK
Definition: vtkImageMathematics.h:225
vtkImageMathematics::SetOperationToMultiplyByK
void SetOperationToMultiplyByK()
Set each pixel in the output image to the product of ConstantK with the corresponding pixel in Input1...
Definition: vtkImageMathematics.h:174
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageMathematics::SetOperationToConjugate
void SetOperationToConjugate()
Definition: vtkImageMathematics.h:97
VTK_SIN
#define VTK_SIN
Definition: vtkImageMathematics.h:38
VTK_SQR
#define VTK_SQR
Definition: vtkImageMathematics.h:43