0% found this document useful (0 votes)
68 views7 pages

Computer Vision Lab Experiment-1: Title: Study of Matlab Image Processing Toolbox

The document describes an experiment conducted using MATLAB's image processing toolbox. The aim was to get familiar with basic image processing commands in MATLAB like imread, imshow, imresize, imcrop, rgb2gray, im2bw and imbinarize. An RGB image of a football was read into MATLAB and then converted to grayscale. The grayscale image was then converted to a binary image and cropped. The RGB image was also resized using imresize to produce smaller and larger images.

Uploaded by

Hari Sh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views7 pages

Computer Vision Lab Experiment-1: Title: Study of Matlab Image Processing Toolbox

The document describes an experiment conducted using MATLAB's image processing toolbox. The aim was to get familiar with basic image processing commands in MATLAB like imread, imshow, imresize, imcrop, rgb2gray, im2bw and imbinarize. An RGB image of a football was read into MATLAB and then converted to grayscale. The grayscale image was then converted to a binary image and cropped. The RGB image was also resized using imresize to produce smaller and larger images.

Uploaded by

Hari Sh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

COMPUTER VISION LAB

EXPERIMENT-1

TITLE: STUDY OF MATLAB


IMAGE PROCESSING TOOLBOX

NAME: KOTANA SAI


LEELA ROLL NO:
221EC6383
DATE OF EXP: 8th Sept 2021
AIM: To get familiarize with MATLAB image processing toolbox.
SOFTWARE USED: MATLAB
THEORY:
MATLAB stands for matrix laboratory. Image processing is
the application of set of techniques used to analyse, enhance and modify the
characteristics of a digital image. An image is defined as a two-dimensional
function, F(x,y) where x, y are spatial co-ordinates, and the amplitude of F at
any (x,y) is called intensity of the image.
Image processing toolbox provides a comprehensive set of
standard algorithms for image processing, analysis, enhancement, restoration,
etc. MATLAB stores images as two-dimensional matrices, in which each
element of the matrix corresponds to a pixel(discrete) of the respective
image.
Types of an image:
 Binary image: It contains only 2-pixel elements i.e; 0&1, where 0
refers to black and 1 refers to white. This image is also known as
Monochrome.
 Black and White image: The image which consists of only black&
white colour is called Black and White image.
 8-bit Colour format: It is the most famous image format. It has 256
different shades of colours in it and commonly known as “Grayscale
Image”. In this format, 0 stands for black, 255 stands for white and 127
for gray.
 16-bit Colour format: It is a colour image format. It has 65,536
different colours in it. It is also known as High Colour format. In this
format, the distribution of colour is not as same as Grayscale image. A
16-bit format is further divided into Red, Green& Blue. 16-bit colour
format is famously known as “RGB format”.

Basic image processing commands in MATLAB are:


 Imread: Images are read in MATLAB environment using the function
‘imread’. It reads grayscale/color image. Syntax of imread is:
A= imread(‘filename’);
where ‘filename’ is the string having complete name of the image,
including its extension.
 Imshow: 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 ‘unit8’ or
double. Simply, in the previous case, A=
imread(‘filename’);
imshow(A);
Now, the output image will be the file that has been read before.
 Imresize: Image can be resized in MATLAB using imresize.
B= imresize(A, scale) returns image B i.e; scale times the size
of image A. The input image A can be a grayscale, RGB or binary
image. B>A, when scale is greater than 1 and B<A, when scale is in
between 0 to 1.
 Imcrop: Imcrop crops an image to a specified rectangle/region. In the
syntax below, imcrop displays the input image and waits for you to
specify the crop rectangle with the mouse.
Syntax: I= imcrop(A);
 Rgb2gray: In MATLAB, the function ‘rgb2gray’ converts the RGB
image into Grayscale image. The syntax is shown below:
G= rgb2gray(A);
returns to a Grayscale image G for an input RGB image A.
 Im2bw: Converts an image to a binary image, based on threshold. It
produces binary image from indexed, intensity or RGB images. To
perform this, it converts the input image to grayscale format (if it’s
not already intensity image), and then converts this grayscale image to
binary image by thresholding.
Syntax: BW= im2bw(A, level);
The output binary BW image has values of 0(black) for all pixels in
the input image with luminance less than the level and 1(white) for all
other pixels. Range of level should be between 0-1.
 Imbinarize: Creates a binary image from 2-D or 3-D grayscale image,
by replacing all the values that are above globally determined threshold
as 1’s and the remaining as 0’s. The function ‘imbinarize’ is same as
‘im2bw’.
Syntax: BI= imbinarize(A);
RESULTS:
DISCUSSION:
1. Read an RGB image using ‘imread’ function with both its filename
and format as an input image.
2. Displayed the input RGB image by using ‘imshow’ function.
3. Converted the RGB image to Gray-scale image using‘rgb2gray’
function by providing RGB image as input and observed the output
grayscale image.
4. Converted the Gray-scale image to binary images using ‘imbinarize’
function by providing grayscale image as input and observedthe
binarized output image.
5. ‘im2bw’ function can also be used to convert grayscale image to
binary image. This function performs same as ‘imbinarize’.
6. Resized the RGB image using ‘imresize’ function with RGB image and
scale as inputs. Obtained two images with scale in the range [0,1],
which resulted in a smaller image compared to the input and with
scale greater than 1, which resulted an image larger than input.
Observed both the output resized images by using ‘imshow’ function.
7. Cropped the input RGB image using ‘imcrop’ by selecting the
specified crop rectangle with the help of mouse. The output is the
cropped image within theselected crop rectangle.

CONCLUSION:
Various image processing commands like imread, imshow, imcrop,
im2bw, imbinarize, rgb2gray, imresize, etc are applied on RGB images
and observed the respective output images using MATLAB.

SOURCE CODE:

clc;
clear all;
close all;
%Reading an image using imread()
A= imread('football.jpg');
figure;
imshow(A); %displays the read image
title('Original Image');
%Cropping the input image using imcrop()
M= imcrop(A);
figure;
imshow(M); %displays the cropped image
title('Cropped Image');
%Converting RGB to Grayscale image
I= rgb2gray(A);
figure;
imshow(I); %displays the Gray image
title('Gray Image');
%Converting Gray image into Binary image using
imbinarize()
B= imbinarize(I);
figure;
imshow(B); %displays the Binary image
title('Binary Image');
%Converting Gray image into Binary by using im2bw()
BI= im2bw(I);
figure;
imshow(BI); %displays the Binary image
title('Binary image using im2bw');
%Resizing the input image with scale between 0-1
C= imresize(A,0.6);
figure;
imshow(C); %displays the image smaller than
input title('Resized Image 1');
%Resizing the input image with scale greater than 1
D= imresize(A,1.6);
figure;
imshow(D); %displays the image larger than input
title('Resized Image 2');

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy