KEMBAR78
Image Representation Practicals | PDF | Rgb Color Model | Pixel
0% found this document useful (0 votes)
28 views4 pages

Image Representation Practicals

This document outlines a laboratory exercise for students in the Biomedical Signals Processing Systems course at the Technical University of Mombasa. The exercise focuses on understanding digital image representation types, manipulating images using MATLAB, and converting between different image formats. Students are required to complete tasks involving loading images, exploring pixel values, and comparing different image representations, along with submitting a MATLAB script and a report with their findings.

Uploaded by

Penina Tabitha
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)
28 views4 pages

Image Representation Practicals

This document outlines a laboratory exercise for students in the Biomedical Signals Processing Systems course at the Technical University of Mombasa. The exercise focuses on understanding digital image representation types, manipulating images using MATLAB, and converting between different image formats. Students are required to complete tasks involving loading images, exploring pixel values, and comparing different image representations, along with submitting a MATLAB script and a report with their findings.

Uploaded by

Penina Tabitha
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/ 4

TECHNICAL UNIVERSITY OF MOMBASA

SCHOOL OF ENGINEERING AND TECHNOLOGY


DEPARTMENT OF MEDICAL ENGINEERING
EBL 4502: BIOMEDICAL SIGNALS PROCESSING SYSTEMS
PRACTICAL LABORATORY EXERCISE I
Title: Image Representation

1 Objective
By the end of this laboratory practical, students will be able to:
1. Understand the different types of digital image representation (grayscale, binary, RGB,
indexed).
2. Work with image data in MATLAB, exploring pixel-level manipulations.
3. Convert between different image formats.
4. Understand how images are stored in memory and the relationship between image
resolution and pixel values.

2 Materials
1. Computer with MATLAB Installed
2. Sample Images (Pre-loaded Images)
3. Laboratory Manual
4. Lab Report Template

3 Procedures (Tasks)
Task 1: Loading and Displaying Images
Step 1: Load an Image into MATLAB
Use the imread function to load a sample image into the workspace.
I = imread('peppers.png'); % You can use any image here
Step 2: Display the Image
Use imshow to display the loaded image.
imshow(I);
title('Original Image');
Explanation:
 MATLAB treats images as matrices of pixel values. An RGB image is a 3D
matrix with dimensions representing the height, width, and three-color channels
(Red, Green, Blue).

©John Boston Odhiambo Page 1 of 4


Task 2: Image Representation Types
Grayscale Image Representation
Step 1: Convert RGB to Grayscale
Convert the loaded RGB image into a grayscale image using rgb2gray.
I_gray = rgb2gray(I);
imshow(I_gray);
title('Grayscale Image');
Step 2: Explore Pixel Values of the Grayscale Image
Use the size function to determine the dimensions of the grayscale image matrix, and
view some pixel values.
size(I_gray) % Output the dimensions of the grayscale image
I_gray(1:50, 1:80) % Display pixel values from the top-left corner
Explanation:
 In a grayscale image, each pixel is represented by a single intensity value
(between 0 and 255 for 8-bit images). These values represent the brightness
level.
Binary Image Representation
Step 1: Convert Grayscale to Binary
Convert the grayscale image into a binary image using a threshold. You can use
imbinarize.
I_bw = imbinarize(I_gray);
imshow(I_bw);
title('Binary Image');
Step 2: Display Binary Pixel Values
Display a portion of the binary image pixel values.
I_bw(1:5, 1:5)
Explanation:
 In a binary image, each pixel is either black (0) or white (1), representing two
intensity levels. Binary images are useful for tasks like segmentation and object
detection.
Indexed Image Representation
Step 1: Convert RGB to Indexed Image
Convert the RGB image into an indexed image using rgb2ind.
[I_indexed, cmap] = rgb2ind(I, 256); % 256-color indexed image
imshow(I_indexed, cmap);
title('Indexed Image');

©John Boston Odhiambo Page 2 of 4


Explanation:
 In an indexed image, pixel values are indices into a color map (a set of
predefined colors). Each pixel does not store RGB values directly but refers to
a row in the color map.
Task 3: Converting Between Image Types
Convert Grayscale to Binary
Step 1: Adjust Threshold Manually
Convert the grayscale image to binary using a manual threshold.
threshold = 0.5;
I_bw_manual = im2bw(I_gray, threshold);
imshow(I_bw_manual);
title('Manually Thresholded Binary Image');
Explanation:
 The im2bw function converts a grayscale image to binary by comparing each
pixel to the threshold value. If the pixel value is greater than the threshold, it is
set to 1 (white); otherwise, it is set to 0 (black).
Task 4: Displaying Image Properties
Step 1: Image Data Type
Use the class function to check the data type of the image matrix.
class(I)
class(I_gray)
Step 2: Display Range of Pixel Values
Check the minimum and maximum pixel values in the grayscale and RGB images.
min(I_gray(:))
max(I_gray(:))
Explanation:
 Image data in MATLAB is typically stored as unsigned integers (uint8),
meaning pixel values are in the range of 0-255. For processing, students may
need to convert the image to double precision.
Task 5: Pixel-Level Manipulations
Step 1: Modify Pixel Values
Modify specific pixel values in the image and observe the effects.
I_modified = I;
I_modified(1:50, 1:50, :) = 0; % Set top-left 50x50 pixels to black
imshow(I_modified);
title('Image with Modified Pixels');

©John Boston Odhiambo Page 3 of 4


Explanation:
 This demonstrates how pixel values can be accessed and modified directly in
MATLAB. The : operator is used to specify the red, green, and blue channels.
Task 6: Comparing Image Representations
Step 1: Display Original vs Grayscale
Use imshowpair to compare the original and grayscale images.
imshowpair(I, I_gray, 'montage');
title('RGB vs Grayscale Image');
Step 2: Display Grayscale vs Binary
Compare the grayscale image and its binary version.
imshowpair(I_gray, I_bw, 'montage');
title('Grayscale vs Binary Image');
Explanation:
 The imshowpair function is useful for side-by-side comparison of different
representations of the same image. Students can clearly see the effect of each
conversion.

4 Post-Lab Questions
1. What are the differences between an RGB image and a grayscale image in terms of
pixel representation?
2. How does MATLAB store an indexed image? Explain the role of the color map.
3. Why do binary images use only two intensity levels, and in which scenarios would
binary images be preferred over grayscale or RGB?
4. How does image resolution affect the size and quality of an image?
5. Explain how manually setting a threshold affects binary image conversion.

5 Deliverables
1. A MATLAB script that contains the code for each task.
2. A report containing screenshots of the images at each stage, with explanations of the
transformations and representations.
3. Answers to the post-lab questions.

©John Boston Odhiambo Page 4 of 4

You might also like