You are on page 1of 6

UTTARA UNIVERSITY

Department of Computer Science & Engineering

Submitted to:
Al Shahriar Rubel.
Lecturer of Department of CSE.
Course title: Computer Vision & Image Processing Sessional.
Course Code: CSES467.

Submitted by:
Sanjida Sharmin Shrestta.
Batch: 46
Id: 2183081017.
Lab No: 02
Lab Topic: Color image Conversion
Date: 9/10/2021
Objectives:
Task 1: To learn how to convert a color image to grayscale image. Also, how to
display both of the images in one screen.

Task 2: To learn how to convert a color image to black and white images using
im2bw and imbinarize functions. Also, how to display the images in one screen.

Question:
Task1: Read a color image and convert it to a grayscale image. Then
display both of them using subplot.

Code:
Output:

Discussion: In this code, we can change an image color in gray using rgb2gray()
function. To read the image we use imread() function and to show the image we
use imshow() function. If we want to show both image in one screen, we have to
use subplot () function, where first two values stand for the matrix size of the
image and the last value stands for in which position the image should show.
Question:
Task2: Read a color image and convert it to two black and white images; one
using im2bw and another using imbinarize. Then display these 3 images using
subplot.

Code:
Output:

Discussion: In this code, we can change an image’s color in Blsck and white
using im2bw() and imbinarize function. To read the image we use imread()
function and to show the image we use imshow() function.
Here, im2bw() function directly converts the image color to black and white. But
imbinarize() function can’t do it directly. First of all this function takes a gray scale
image and then convert it to black and white image.
If we want to show the images in one screen, we have to use subplot () function,
where first two values stand for the matrix size of the image and the last value
stands for, in which position the image should show.

You might also like