You are on page 1of 3

Laboratory Experiment 1

1801173 Lunar, Allen Emerson F.


1802258 Navarro, John Lloyd R.

Image Arithmetic Functions

Learning Outcome
At the end of the exercise, the student will be able to:
1. Perform standard arithmetic operations such as addition, subtraction, multiplication, and
division on images.
2. Identify the effects of the different arithmetic operations on images.

Image arithmetic is the implementation of standard arithmetic operations on images. In image


processing, it can be used as a preliminary step in more complex operations (i.e. image subtraction can
be used to detect differences between two or more images of the same scene or object).

One can perform image arithmetic using the Matlab arithmetic operators. The Image Processing
Toolbox includes a set of functions that implement arithmetic operations for all numeric, nonsparse data
types such as uint8, uint16, and double, and return the result image in the same format. These functions
perform the operations in double precision, on an element-by-element basis, but do not convert images
to double-precision values in the workspace. Overflow is handled automatically. The functions saturate
return values to fit the data type.

These arithmetic operations act by applying a simple function to each grey value in the image:
y=f(x)
Thus f(x) is a function which maps the range 0-255 onto itself. Simple functions include adding or
subtracting a constant value to each pixel:
y = x + C or y = x - C
and multiplying or dividing each pixel by a constant:
y = C x or y = x / C
In each case, performing these operations may result to values outside the range of 0-255. To ensure
that the results are within the range, we need to round off the values to obtain an integer and then
clipping the values:
If y > 255, then y = 255 or if y < 0, then y = 0
It should be noted that Matlab handles this case automatically.

Procedure
1. We can test this on the image “cameraman.tif”. We start by reading the image in:
>> y = imread (‘cameraman.tif’);
>>figure (1), imshow (y)
Copy the image and place it the space provided under the label “Figure 1. Original Image”
2. Perform addition on the image by entering either of the commands:
>> Add_y = y + 128;
or

1
Laboratory Experiment 1

>> Add_y = imadd ( y, 128 );


>>figure (2), imshow (Add_y)
Copy the image and place it the space provided under the label “Figure 2. Addition”
3. Perform subtraction on the image by entering either of the commands:
>> Sub_y = y + 128;
or
>> Sub_y = imsubtract ( y, 128 );
>> figure (3), imshow (Sub_y)
Copy the image and place it the space provided under the label “Figure 3. Subtraction”
4. Perform multiplication on the image by entering either of the commands:
>> Mul_y = y * 2;
or
>> Mul_y = immultiply ( y, 2 );
>> figure (4), imshow (Mul_y)
Copy the image and place it the space provided under the label “Figure 4. Multiplication”
5. Perform division on the image by entering either of the commands:
>> Div_y = y / 2;
or
>> Div_y = imdivide ( y, 2 );
>> figure (5), imshow (Div_y)
Copy the image and place it the space provided under the label “Figure 1. Division”

Figure 1. Original Image Figure 2. Addition Figure 3. Subtraction

2
Laboratory Experiment 1

Figure 4. Multiplication Figure 5. Division


Questions
1. What have you observed on the image after the following arithmetic operations were
performed?

a. Addition

The brightness of the image was intensified.

b. Subtraction

Contrary to what the operation might imply, the brightness of the image was also intensified,
similar to the addition operation.

c. Multiplication

The contrast was significantly increased, as seen in the more intense black. It is easier to
distinguish the black from the white.

d. Division

The contrast was significantly decreased. The black and white parts of the image are slightly
harder to distinguish.

2. What generalization can you come up?


MATLAB is capable of modifying an image’s brightness/contrast levels. The image would have to
be imported first. Through arithmetic operations, one can manipulate the image;
addition/multiplication to increase levels, subtraction/division to decrease.

You might also like