Image Calculator

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. The tool also provides a method for computing statistics over images in multiple color spaces. Statistics are taken over a mask defined by a binary image, which can be created using a segmentation tool such as Seg2DBall. This additional functionality is described at the end of the document.

Description: The methods supported by ImageCalculator 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, unless they are not of the same type. In this case it will create the output of the type of the image that is bigger, with double being the biggest and byte being the smallest.

The ImageCalculator performs the following algebraic and boolean operations:

Addition

Subtraction

Inversion

Multiplication

Division

Average

Boolean AND

Boolean OR

Boolean XOR

Setup: In order to execute any operation, two images have to be loaded and thus set as the two operands for the chosen calculation. The image loaded into the frame, by using "LoadIntoFrame", is the first operand (obviously this only matters for Subtract, Divide and Inverse). Thus the FrameImage is the image which the operation is performed on. Loading an image using "Load Image" will make it the second operand, or as I refer to it the ActionImage, which seemed logical because it is the one performing the operation. Therefore if you Subtract/Divide you will Sub/Div the ActionImage from the FrameImage. Inversion is performed on the FrameImage.

Run: In order to run the tool two images will have to be loaded. A FrameImage ("LoadIntoFrame") and a ActionImage ("Load Image"). Following the desired operation shoud be chosen from the dropdown menu (Add, Subtract, etc) and by pressing the "Execute" Button the calculation will take place and deliver a result which will pop up in a new frame. If one should close the ResultFrame or the ActionImage frame there are buttons two buttons ("Show Image", "Show Result") which will make the image in question appear in a new frame. The ResultImage can be put into the mainframe by utilizing "ResultIntoFrame" and thus it will become the FrameImage which means that operations are now performed on that image.

The summary of the additional buttons is provided next:

Load Image - Loads the second operand and shows the image.

LoadIntoFrame - Loads the first operand and displays it in the mainframe.

Load Many - Loads more than two images, they are not displayed, only "Average Many" can be performed.

Execute - The chosen action from the ComboBox will be performed with the images.

Show Result - displays the result image in a new frame

Save Result - saves the result image.

Example ADD:




Color Space Statistics and Maksing Tool

Description:

This tool allows the user to compute color statistics over specific regions of an image in a selected color space. It was developed to assist in comparing color use between multiple artists painting a specific type of material (such as skin).

Run:

The image and binary mask are loaded as the first and second arguments, respectively, as shown below. The ApplyMask option is then selected from the drop-down menu. Once this option is selected, the color space menu becomes accessible and the desired color space may be selected. Clicking the Execute button now produces a masked image in the desired color space, as well as mean and standard deviation information for each band over the mask. If desired, a histogram can also be generated using the Generate Histogram over Mask button.




Example:

Example output from the ApplyMask operation is shown in the diagram below. The original image and masked image in the YIQ color space are shown in the top left and right, respectively. The statistics for each band are shown in the bottom left, where A = Y, B = I, and C = Q in this case. Finally, a histogram is shown in the bottom right, where red, green, and blue correspond to the first, second, and third color bands, respectively. Note that histogram data is accessible through the histogram plot, so that more detailed statistics can be computed using a spreadsheet program if needed.



Release notes: author Peter Bajcsy & Peter Ferak, version 2.0
Tenzing Shaw (color space statistics tool)