Lab2 - Arithmetic and Logic Opertaions
Lab2 - Arithmetic and Logic Opertaions
Student Id No:
Pre-lab Session In-Lab Session Post Lab session Viva Total Marks
work (5M) work (15M) work (5M) (5M) 30M
Remarks if any:
Image arithmetic applies one of the standard arithmetic operations or a logical operator
to two or more images. The operators are applied in a pixel-by-pixel way, i.e. the value of a
pixel in the output image depends only on the values of the corresponding pixels in the input
images. Hence, the images must be of the same size. Although image arithmetic is the
simplest form of image processing, there is a wide range of applications. A main advantage
of arithmetic operators is that the process is very simple and therefore fast.
Logical operators are often used to combine two (mostly binary) images. In the case of
integer images, the logical operator is normally applied in a bitwise way.
In this lecture we will talk about arithmetic operations such as subtraction and averaging as
well as logic operations such as Not, AND, and OR. In this lecture we will see how we can
remove noise from an image by using image averaging.
Objectives:
To
2.1.1 Image Addition: To add two images or a constant value, use ‘imadd’ function which is
built in function. Imadd method can be used to brighten an image by adding a constant value
to each pixel.
Lab2-Exercise Questions
Exercise2: Consider the following figure. Write a Matlab program to extract the appropriate
rectangular portion of the image (shown in a red color rectangular) and display in a separate
window. Identify the size of the resultant image and calculate the memory size.
Exercise3: Consider the following figure which is a rectangular in size. Write a matlab
program to display the image in a suitable square image (2n X2n).
imtool(J,'DisplayRange',[]);
Exercise4: Consider the following image of size 180X180. Develop Matlab code to display
the image using arithmetic and logic operations.
Digital Image Processing Lab, Dept. of ECE, KL University, A.P., India. Student Id No:
Exercise5: Write a Matlab code to read and display an image 'board.tif'. Now
display a portion of the image that has the dimensions of 256X256.
Exercise6: Enter the following Matlab code and observe the results
clear; close all; clc;
im = imread('cameraman.tif');
im1=imdivide(im,64);
im2=immultiply(im1,64);
figure();
subplot(1,3,1); imshow(im,[]); title('Original Image');
subplot(1,3,2); imshow(im1,[]); title('Divided by 4');
subplot(1,3,3); imshow(im2,[]); title('Multiply by 4');
Comment on the result. Why is the result not equivalent to the original image?