VTK  9.5.20250802
vtkImageMathematics.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
125#ifndef vtkImageMathematics_h
126#define vtkImageMathematics_h
127
128// Operation options.
129#define VTK_ADD 0
130#define VTK_SUBTRACT 1
131#define VTK_MULTIPLY 2
132#define VTK_DIVIDE 3
133#define VTK_INVERT 4
134#define VTK_SIN 5
135#define VTK_COS 6
136#define VTK_EXP 7
137#define VTK_LOG 8
138#define VTK_ABS 9
139#define VTK_SQR 10
140#define VTK_SQRT 11
141#define VTK_MIN 12
142#define VTK_MAX 13
143#define VTK_ATAN 14
144#define VTK_ATAN2 15
145#define VTK_MULTIPLYBYK 16
146#define VTK_ADDC 17
147#define VTK_CONJUGATE 18
148#define VTK_COMPLEX_MULTIPLY 19
149#define VTK_REPLACECBYK 20
150
151#include "vtkImagingMathModule.h" // For export macro
153
154VTK_ABI_NAMESPACE_BEGIN
155// Excluded from JavaScript wrapping because it provides overloads for SetInputConnection which
156// take precedence for all vtkAlgorithm(s)
159{
160public:
163 void PrintSelf(ostream& os, vtkIndent indent) override;
164
166
169 vtkSetMacro(Operation, int);
170 vtkGetMacro(Operation, int);
172
177 void SetOperationToAdd() { this->SetOperation(VTK_ADD); }
178
183 void SetOperationToSubtract() { this->SetOperation(VTK_SUBTRACT); }
184
189 void SetOperationToMultiply() { this->SetOperation(VTK_MULTIPLY); }
190
195 void SetOperationToDivide() { this->SetOperation(VTK_DIVIDE); }
196
197 void SetOperationToConjugate() { this->SetOperation(VTK_CONJUGATE); }
198
200
205 void SetOperationToInvert() { this->SetOperation(VTK_INVERT); }
206
211 void SetOperationToSin() { this->SetOperation(VTK_SIN); }
212
217 void SetOperationToCos() { this->SetOperation(VTK_COS); }
218
223 void SetOperationToExp() { this->SetOperation(VTK_EXP); }
224
229 void SetOperationToLog() { this->SetOperation(VTK_LOG); }
230
235 void SetOperationToAbsoluteValue() { this->SetOperation(VTK_ABS); }
236
241 void SetOperationToSquare() { this->SetOperation(VTK_SQR); }
242
247 void SetOperationToSquareRoot() { this->SetOperation(VTK_SQRT); }
248
253 void SetOperationToMin() { this->SetOperation(VTK_MIN); }
254
259 void SetOperationToMax() { this->SetOperation(VTK_MAX); }
260
265 void SetOperationToATAN() { this->SetOperation(VTK_ATAN); }
266
267 void SetOperationToATAN2() { this->SetOperation(VTK_ATAN2); }
268
273 void SetOperationToMultiplyByK() { this->SetOperation(VTK_MULTIPLYBYK); }
274
279 void SetOperationToAddConstant() { this->SetOperation(VTK_ADDC); }
280
285 void SetOperationToReplaceCByK() { this->SetOperation(VTK_REPLACECBYK); }
286
288
291 vtkSetMacro(ConstantK, double);
292 vtkGetMacro(ConstantK, double);
294
296
299 vtkSetMacro(ConstantC, double);
300 vtkGetMacro(ConstantC, double);
302
304
307 vtkSetMacro(DivideByZeroToC, vtkTypeBool);
308 vtkGetMacro(DivideByZeroToC, vtkTypeBool);
309 vtkBooleanMacro(DivideByZeroToC, vtkTypeBool);
311
313
317 virtual void SetInput1Data(vtkDataObject* in) { this->SetInputData(0, in); }
318 virtual void SetInput2Data(vtkDataObject* in) { this->AddInputData(0, in); }
319 void SetInputConnection(int idx, vtkAlgorithmOutput* input) override;
321 {
322 this->SetInputConnection(0, input);
323 }
325
332 virtual void ReplaceNthInputConnection(int idx, vtkAlgorithmOutput* input);
333
335
340 void SetInputData(int idx, vtkDataObject* input);
341 void SetInputData(vtkDataObject* input) { this->SetInputData(0, input); }
343
345
351 vtkDataObject* GetInput() { return this->GetInput(0); }
353
360
361protected:
363 ~vtkImageMathematics() override = default;
364
366 double ConstantK;
367 double ConstantC;
369
371
373 vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
374 int outExt[6], int threadId) override;
375
376 int FillInputPortInformation(int port, vtkInformation* info) override;
377
378private:
380 void operator=(const vtkImageMathematics&) = delete;
381};
382
383VTK_ABI_NAMESPACE_END
384#endif
Proxy object to connect input/output ports.
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
int GetNumberOfInputConnections(int port)
Get the number of inputs currently connected to a port.
general representation of visualization data
void SetInputData(vtkDataObject *)
Assign a data object as input.
virtual void AddInputData(vtkDataObject *)
Assign a data object as input.
topologically and geometrically regular array of data
Add, subtract, multiply, divide, invert, sin, cos, exp, log.
void SetOperationToMultiply()
Set each pixel in the output image to the product of the corresponding pixels in Input1 and Input2.
void SetOperationToATAN()
Set each pixel in the output image to the arctangent of the corresponding pixel in Input1.
void SetInputConnection(int idx, vtkAlgorithmOutput *input) override
Set the inputs to this filter.
vtkDataObject * GetInput(int idx)
Get one input to this filter.
virtual void SetInput1Data(vtkDataObject *in)
Set the inputs to this filter.
void SetOperationToMultiplyByK()
Set each pixel in the output image to the product of ConstantK with the corresponding pixel in Input1...
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,...
~vtkImageMathematics() override=default
void SetOperationToSquareRoot()
Set each pixel in the output image to the square root of the corresponding pixel in Input1.
void SetOperationToMin()
Set each pixel in the output image to the minimum of the corresponding pixels in Input1 and Input2.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetInputConnection(vtkAlgorithmOutput *input) override
Set the inputs to this filter.
virtual void ReplaceNthInputConnection(int idx, vtkAlgorithmOutput *input)
Replace one of the input connections with a new input.
void SetInputData(vtkDataObject *input)
Assign a data object as input.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetInput2Data(vtkDataObject *in)
Set the inputs to this filter.
void SetOperationToDivide()
Set each pixel in the output image to the quotient of the corresponding pixels in Input1 and Input2 (...
void SetOperationToExp()
Set each pixel in the output image to the exponential of the corresponding pixel in Input1.
void SetInputData(int idx, vtkDataObject *input)
Assign a data object as input.
void SetOperationToSubtract()
Set each pixel in the output image to the difference of the corresponding pixels in Input1 and Input2...
void SetOperationToLog()
Set each pixel in the output image to the log of the corresponding pixel in Input1.
void SetOperationToMax()
Set each pixel in the output image to the maximum of the corresponding pixels in Input1 and Input2.
void SetOperationToAdd()
Set each pixel in the output image to the sum of the corresponding pixels in Input1 and Input2.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
int GetNumberOfInputs()
Get the number of inputs to this filter.
void SetOperationToReplaceCByK()
Find every pixel in Input1 that equals ConstantC and set the corresponding pixels in the Output to Co...
void SetOperationToSin()
Set each pixel in the output image to the sine of the corresponding pixel in Input1.
void SetOperationToAddConstant()
Set each pixel in the output image to the product of ConstantC with the corresponding pixel in Input1...
void SetOperationToAbsoluteValue()
Set each pixel in the output image to the absolute value of the corresponding pixel in Input1.
static vtkImageMathematics * New()
void SetOperationToSquare()
Set each pixel in the output image to the square of the corresponding pixel in Input1.
void SetOperationToInvert()
Set each pixel in the output image to 1 over the corresponding pixel in Input1 and Input2 (output = 1...
vtkDataObject * GetInput()
Get one input to this filter.
void SetOperationToCos()
Set each pixel in the output image to the cosine of the corresponding pixel in Input1.
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Generic filter that has one input.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SQRT
#define VTK_MULTIPLYBYK
#define VTK_LOG
#define VTK_ATAN
#define VTK_ATAN2
#define VTK_INVERT
#define VTK_SUBTRACT
#define VTK_EXP
#define VTK_MIN
#define VTK_MULTIPLY
#define VTK_COMPLEX_MULTIPLY
#define VTK_SIN
#define VTK_ABS
#define VTK_COS
#define VTK_ADD
#define VTK_SQR
#define VTK_MAX
#define VTK_REPLACECBYK
#define VTK_ADDC
#define VTK_CONJUGATE
#define VTK_DIVIDE
#define VTK_WRAPEXCLUDE_JAVASCRIPT