0% found this document useful (0 votes)
17 views3 pages

CPE415 Lab 2

The document outlines a lab exercise focused on displaying and converting various types of images using MATLAB. It covers image types such as binary, grayscale, RGB, and indexed images, along with methods for displaying images, extracting information, and converting between formats. The lab includes pre-lab tasks, in-lab tasks, and a rubric for assessing student performance.

Uploaded by

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

CPE415 Lab 2

The document outlines a lab exercise focused on displaying and converting various types of images using MATLAB. It covers image types such as binary, grayscale, RGB, and indexed images, along with methods for displaying images, extracting information, and converting between formats. The lab includes pre-lab tasks, in-lab tasks, and a rubric for assessing student performance.

Uploaded by

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

LAB # 2: To display various types of images, image information

and conversion of images and data types using MATLAB.


Objective
• To understand different types of images used in image processing.
• To learn how to display images in MATLAB.
• To extract image information such as size, dimensions, and class.
• To convert between different image types and data formats.

Pre-Lab

2.1 Types of Images in Digital Image Processing


• Binary Image: Consists of only two pixel values: 0 (black) and 1 (white).
• Grayscale Image: Each pixel has a value between 0 and 255 (for 8-bit images).
• RGB Image: Consists of three channels (Red, Green, and Blue), each having values
between 0 and 255.
• Indexed Image: Uses a colormap where pixel values are indices to a colour table.

2.2 Displaying Images in MATLAB


To display an image in MATLAB, we use:

img = imread('image.jpg'); % Read image from file


imshow(img); % Display image

2.3 Extracting Image Information


We can retrieve various details about an image using MATLAB functions:

img = imread('image.jpg');
info = imfinfo('image.jpg'); % Get image information
size(img) % Get dimensions
class(img) % Get data type

2.4 Image Type Conversion


MATLAB provides functions to convert images between different types:

2.4.1 Convert RGB to Grayscale:


gray_img = rgb2gray(img);
imshow(gray_img);

2.4.2 Convert Grayscale to Binary:


binary_img = imbinarize(gray_img);
imshow(binary_img);

2.4.3 Convert Image Data Type:


img_double = im2double(img); % Convert to double precision
img_uint8 = im2uint8(img_double); % Convert back to uint8

Engr. Moazzam Ali Sahi |CPE415 | Digital Image Processing Lab Manual
Lab Experiment | 2

Pre-Lab Task
1. Research different image types and their applications.
2. Install MATLAB and ensure the Image Processing Toolbox is available.
3. Find and download sample images (grayscale, RGB, indexed) to use in the lab.

In-Lab Tasks

Lab Task 1: Display Different Image Types


a) Load and display a binary, grayscale, and RGB image using imshow.

Lab Task 2: Extract Image Information:


a) Use MATLAB functions to display the size, dimensions, and type of an image.

Lab Task 3: Convert Image Types:


a) Convert an RGB image to grayscale.
b) Convert a grayscale image to binary.
c) Convert image data types (uint8 to double and vice versa).

Lab Task 4: Compare and Analyze:


a) Observe changes in pixel values during conversions.
b) Save and display converted images using imwrite.

Engr. Moazzam Ali Sahi |CPE415 | Digital Image Processing Lab Manual
Lab Experiment | 2

Rubric for Lab Assessment

The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from the
Excellent 4
instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1

Instructor Signature: ______________________ Date:________________

Engr. Moazzam Ali Sahi |CPE415 | Digital Image Processing Lab Manual

You might also like