VTK  9.2.6
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 // Operation options.
32 #define VTK_ADD 0
33 #define VTK_SUBTRACT 1
34 #define VTK_MULTIPLY 2
35 #define VTK_DIVIDE 3
36 #define VTK_INVERT 4
37 #define VTK_SIN 5
38 #define VTK_COS 6
39 #define VTK_EXP 7
40 #define VTK_LOG 8
41 #define VTK_ABS 9
42 #define VTK_SQR 10
43 #define VTK_SQRT 11
44 #define VTK_MIN 12
45 #define VTK_MAX 13
46 #define VTK_ATAN 14
47 #define VTK_ATAN2 15
48 #define VTK_MULTIPLYBYK 16
49 #define VTK_ADDC 17
50 #define VTK_CONJUGATE 18
51 #define VTK_COMPLEX_MULTIPLY 19
52 #define VTK_REPLACECBYK 20
53 
54 #include "vtkImagingMathModule.h" // For export macro
56 
57 class VTKIMAGINGMATH_EXPORT vtkImageMathematics : public vtkThreadedImageAlgorithm
58 {
59 public:
60  static vtkImageMathematics* New();
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
65 
68  vtkSetMacro(Operation, int);
69  vtkGetMacro(Operation, int);
71 
76  void SetOperationToAdd() { this->SetOperation(VTK_ADD); }
77 
82  void SetOperationToSubtract() { this->SetOperation(VTK_SUBTRACT); }
83 
88  void SetOperationToMultiply() { this->SetOperation(VTK_MULTIPLY); }
89 
94  void SetOperationToDivide() { this->SetOperation(VTK_DIVIDE); }
95 
96  void SetOperationToConjugate() { this->SetOperation(VTK_CONJUGATE); }
97 
98  void SetOperationToComplexMultiply() { this->SetOperation(VTK_COMPLEX_MULTIPLY); }
99 
104  void SetOperationToInvert() { this->SetOperation(VTK_INVERT); }
105 
110  void SetOperationToSin() { this->SetOperation(VTK_SIN); }
111 
116  void SetOperationToCos() { this->SetOperation(VTK_COS); }
117 
122  void SetOperationToExp() { this->SetOperation(VTK_EXP); }
123 
128  void SetOperationToLog() { this->SetOperation(VTK_LOG); }
129 
134  void SetOperationToAbsoluteValue() { this->SetOperation(VTK_ABS); }
135 
140  void SetOperationToSquare() { this->SetOperation(VTK_SQR); }
141 
146  void SetOperationToSquareRoot() { this->SetOperation(VTK_SQRT); }
147 
152  void SetOperationToMin() { this->SetOperation(VTK_MIN); }
153 
158  void SetOperationToMax() { this->SetOperation(VTK_MAX); }
159 
164  void SetOperationToATAN() { this->SetOperation(VTK_ATAN); }
165 
166  void SetOperationToATAN2() { this->SetOperation(VTK_ATAN2); }
167 
172  void SetOperationToMultiplyByK() { this->SetOperation(VTK_MULTIPLYBYK); }
173 
178  void SetOperationToAddConstant() { this->SetOperation(VTK_ADDC); }
179 
184  void SetOperationToReplaceCByK() { this->SetOperation(VTK_REPLACECBYK); }
185 
187 
190  vtkSetMacro(ConstantK, double);
191  vtkGetMacro(ConstantK, double);
193 
195 
198  vtkSetMacro(ConstantC, double);
199  vtkGetMacro(ConstantC, double);
201 
203 
206  vtkSetMacro(DivideByZeroToC, vtkTypeBool);
207  vtkGetMacro(DivideByZeroToC, vtkTypeBool);
208  vtkBooleanMacro(DivideByZeroToC, vtkTypeBool);
210 
212 
216  virtual void SetInput1Data(vtkDataObject* in) { this->SetInputData(0, in); }
217  virtual void SetInput2Data(vtkDataObject* in) { this->AddInputData(0, in); }
218  virtual void SetInputConnection(int idx, vtkAlgorithmOutput* input) override;
219  virtual void SetInputConnection(vtkAlgorithmOutput* input) override
220  {
221  this->SetInputConnection(0, input);
222  }
224 
231  virtual void ReplaceNthInputConnection(int idx, vtkAlgorithmOutput* input);
232 
234 
239  void SetInputData(int idx, vtkDataObject* input);
240  void SetInputData(vtkDataObject* input) { this->SetInputData(0, input); }
242 
244 
249  vtkDataObject* GetInput(int idx);
250  vtkDataObject* GetInput() { return this->GetInput(0); }
252 
259 
260 protected:
262  ~vtkImageMathematics() override = default;
263 
265  double ConstantK;
266  double ConstantC;
268 
270 
271  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
272  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
273  int outExt[6], int threadId) override;
274 
275  int FillInputPortInformation(int port, vtkInformation* info) override;
276 
277 private:
278  vtkImageMathematics(const vtkImageMathematics&) = delete;
279  void operator=(const vtkImageMathematics&) = delete;
280 };
281 
282 #endif
int GetNumberOfInputConnections(int port)
Get the number of inputs currently connected to a port.
void SetOperationToATAN()
Set each pixel in the output image to the arctangent of the corresponding pixel in Input1...
void SetOperationToAdd()
Set each pixel in the output image to the sum of the corresponding pixels in Input1 and Input2...
void SetOperationToSquareRoot()
Set each pixel in the output image to the square root of the corresponding pixel in Input1...
void SetOperationToSin()
Set each pixel in the output image to the sine of the corresponding pixel in Input1.
#define VTK_SQR
void SetOperationToLog()
Set each pixel in the output image to the log of the corresponding pixel in Input1.
Store vtkAlgorithm input/output information.
#define VTK_SQRT
virtual void SetInput2Data(vtkDataObject *in)
Set the inputs to this filter.
#define VTK_ADDC
#define VTK_ADD
void SetOperationToMin()
Set each pixel in the output image to the minimum of the corresponding pixels in Input1 and Input2...
int GetNumberOfInputs()
Get the number of inputs to this filter.
void SetOperationToDivide()
Set each pixel in the output image to the quotient of the corresponding pixels in Input1 and Input2 (...
#define VTK_MAX
vtkDataObject * GetInput()
Get a data object for one of the input port connections.
#define VTK_COS
#define VTK_MULTIPLY
void SetInputData(vtkDataObject *)
Assign a data object as input.
void SetInputData(vtkDataObject *input)
Assign a data object as input.
#define VTK_ABS
Proxy object to connect input/output ports.
void SetOperationToAbsoluteValue()
Set each pixel in the output image to the absolute value of the corresponding pixel in Input1...
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DIVIDE
Generic filter that has one input.
#define VTK_CONJUGATE
#define VTK_INVERT
#define VTK_SUBTRACT
#define VTK_MULTIPLYBYK
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...
void SetOperationToSubtract()
Set each pixel in the output image to the difference of the corresponding pixels in Input1 and Input2...
void SetOperationToReplaceCByK()
Find every pixel in Input1 that equals ConstantC and set the corresponding pixels in the Output to Co...
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
void SetOperationToExp()
Set each pixel in the output image to the exponential of the corresponding pixel in Input1...
#define VTK_ATAN
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.
void SetOperationToMultiplyByK()
Set each pixel in the output image to the product of ConstantK with the corresponding pixel in Input1...
#define VTK_REPLACECBYK
vtkDataObject * GetInput()
Get one input to this filter.
void SetOperationToSquare()
Set each pixel in the output image to the square of the corresponding pixel in Input1.
Add, subtract, multiply, divide, invert, sin, cos, exp, log.
void SetOperationToMax()
Set each pixel in the output image to the maximum of the corresponding pixels in Input1 and Input2...
#define VTK_MIN
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
#define VTK_LOG
virtual void SetInputConnection(vtkAlgorithmOutput *input) override
Set the inputs to this filter.
#define VTK_EXP
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.
#define VTK_SIN
void SetOperationToInvert()
Set each pixel in the output image to 1 over the corresponding pixel in Input1 and Input2 (output = 1...
void SetOperationToMultiply()
Set each pixel in the output image to the product of the corresponding pixels in Input1 and Input2...
#define VTK_ATAN2
general representation of visualization data
Definition: vtkDataObject.h:65
void SetOperationToCos()
Set each pixel in the output image to the cosine of the corresponding pixel in Input1.
virtual void SetInput1Data(vtkDataObject *in)
Set the inputs to this filter.
#define VTK_COMPLEX_MULTIPLY
virtual void AddInputData(vtkDataObject *)
Assign a data object as input.
void SetOperationToAddConstant()
Set each pixel in the output image to the product of ConstantC with the corresponding pixel in Input1...