The class ImCalculator provides a tool for performing algebraic and boolean operations
with images. The algebraic operations are image addition, subtraction, inversion, multiplication, division
and average. The boolean operations include AND, OR and XOR.
Description: The methods supported by ImCalculator class operate on images at the level of each
image pixel. For example, two color images with red, green and blue bands will be added by summing
spatially corresponding pixel values in each band. While the number of bands and data type must be
consistent in both input images, the image size can vary. The result image will have the spatial dimension
based on the minimum of input image dimensions. If the result of any algebraic operation leads to a value
that is outside the bounds of the input data type, then all resulting values are scaled so that
the output image contains data of the same data type as the input images. Input data type, such as BYTE and SHORT,
are treated as unsigned values.
The following abbreviations are used in the ImCalculator Dialog to denote algebraic and boolean operations:
ADD - addition
SUB - subtraction
INV - inversion
MUL - multiplication
DIV - division
AVG - average
AND - boolean AND
OR - boolean OR
XOR - boolean XOR
Setup: In order to execute any operation, one has to define the operands and the operator.
The first operand (image) is always the content of the memory denoted as STO (stored image). Thus, to set
the first operand after opening an ImCalculator Dialog, press the "STO" button to store the current image from
the main window as the first operand. The second operand is the source image displayed in
the main window frame. The only operation that requires one operand is "INV" (image inversion) and it operates
on the first operand stored by pressing "STO".
Run: To run the tool, open an image in the main window that should be the first operand. Press the button "STO". Open another image in the main window that should be the second operand. Press, for example, "ADD" if
the input images (operands) should be added. View the result by clicking "ShowRES". One can save the result
image by clicking on "SaveRes". While, the second operand is always displayed in the main window frame,
the first operand (image) can be viewed by pressing "ShowSTO".
Similar to standard numerical calculators, one can clear the first operand by pressing "ClrSTO" and exchange
the content of the first operator and the result image by using "RES<->STO". If the stored image (STO) and
the result image (RES) are visible then they will be updated every time there is a change in their content.
The summary of the additional buttons is provided next:
STO - stores the first operand into memory
ShowSTO - displays the content of STO (first operand) in a new frame
RES<->STO - exchanges the content of STO (first operand) and RES (result image)
ShowRES - displays the content of RES (result image) in a new frame
ClrSTO - clears the content of STO (first operand)
SaveRES - saves RES (result image)
Example: Example of image operands (left - 1st operand, middle - 2nd operand) and the result image of ADD operation.
Release notes:
The data types currently supported are BYTE and SHORT.