You are on page 1of 5

Bansilal Ramnath Agarwal Charitable Trust’s

Vishwakarma Institute of Technology

Third Year (Electronics and Telecommunication)

Academic Year 2021-22

Signal Processing Lab Report

Expt. No. 5

Name :- Ruturaj Uttarwar

Div :- ET-D (Batch 3)

Roll No :- 60

Title :- To perform Basics Image processing operations in matlab.

Hardware used :- PC Software used:- MATLAB

Theory :-

Image processing is the technique to convert an image into digital format and
perform operations on it to get an enhanced image or extract some useful
information from it. A digital image may be defined as a two-dimensional function
f(x,y), where ‘x’ and ‘y’ are spatial coordinates and the amplitude of ‘f’ at any pair
of coordinates is called the intensity of the image at that point. When ‘x,’ ‘y’ and
amplitude values of ‘f’ are all finite discrete quantities, the image is referred to as a
digital image.
Basic image processing commands in MATLAB:

 Images are read in MATLAB environment using the function ‘imread.’


Syntax of imread is:
Imread(“filename”), where ‘filename’ is a string having the complete name
of the image, including its extension.
 Images are displayed on the MATLAB desktop using the function imshow,
which has the basic syntax:
imshow(f), where ‘f’ is an image array of data type ‘uint8’ or double. Data
type ‘uint8’ restricts the values of integers between 0 and 255.
Bansilal Ramnath Agarwal Charitable Trust’s

Vishwakarma Institute of Technology

 Multiple images can be displayed within one figure using the subplot
function. This function has three parameters within the brackets:
subplot(a,b,c), where the first two parameters specify the number of rows
and columns to divide the figure.
 Images are written to the current directory using the imwrite function, which
has the following syntax:
Imwrite(f,”filename”), This command writes image data ‘f’ to the file
specified by ‘filename’ in your current folder.
 The imhist function creates a histogram plot by defining n equally spaced
bins, each representing a range of data values, and then calculating the
number of pixels within each range.
Imhist();

Code :-

1. Image read and write

clc;
clear all;
close all;
img = imread('image.jpg');
imshow(img)
imwrite(img, 'image_1.png');
img = imread('cameraman.tif');
subplot(2,2,1);
imshow(img)
title('Original Image');
subplot(2,2,3);
imhist(img)
title('Historgram');
binaryImg = zeros(256, 256);
for i=1: 256
for j=1: 256
if img(i,j) >= 128
binaryImg(i,j) = 255;
else
binaryImg(i,j) = 0;
Bansilal Ramnath Agarwal Charitable Trust’s

Vishwakarma Institute of Technology

end
end
end
subplot(2,2,2);
imshow(binaryImg)
title('Binary Image');
subplot(2,2,4);
imhist(binaryImg)
title('Historgram');

2. Image Negation

clc;
clear all;
close all;

img = imread('cameraman.tif');

subplot(2,2,1);
imshow(img)
title('Original Image');

subplot(2,2,3);
imhist(img)
title('Historgram');

dim = size(img);
row = dim(1);
col = dim(2);

for i = 1 : row
for j = 1 : row

new_img(i, j) = 255 - img(i,j);

end
end

subplot(2,2,2);
imshow(new_img)
title('Negative Image');

subplot(2,2,4);
imhist(new_img)
title('Historgram');
Result :-
1]
Bansilal Ramnath Agarwal Charitable Trust’s

Vishwakarma Institute of Technology

2] Image Negation

Conclusion :-
Bansilal Ramnath Agarwal Charitable Trust’s

Vishwakarma Institute of Technology

In this experiment basics of image processing were performed like reading and
writing of image, plotting of image histogram, potting its subplot and creating its
binary and negative image and performing basic operations on it.

You might also like