TD 1 Computer Vision

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Computer Vision January 2017

Travaux Diriges #1

Objectives:

1) Learn how to read an image file using MATLAB


2) Learn about image type conversion
3) Learn how to display an image using MATLAB
4) Learn how to explore the pixel content of an image
5) Learn how to save an image to a file using MATLAB

Procedure:

1) Load into memory the image coins.png by executing the following statement:

I = imread (‘coins.png’);

What type of image is coins.png?

What happen when you omit the semicolon?

2) Load the image trees.tif using the statement:

[X, map] = imread (‘trees.tif’);

What information do you retrieve in map?

3) Convert the indexed image X with color map “map” to an RGB image, X_rgb by executing the
following statement:

X_rgb = ind2rgb(X, map);

How many dimensions does the variable X_rgb have and what are their sizes?

4) Convert the indexed image X with color map “map” to an intensity image by running the
following command:

X_gray = ind2gray(X,map’);

What type of image is X_gray?

5) Find the value of pixel with the lowest intensity in X_gray using the statement:

min_val = min(X_gray(:));

What is the value of the pixel with the highest intensity in X_gray?

Why are we using the colon(:) operator in the previous command?


6) We can get more intensity level in the quantization process by converting the image to a different
class such as double, or uint16 by doing:

X_gray_dbl = im2double(X_gray);

Or X_gray_dbl = im2uint16(X_gray);

How many gray levels do we have in class uint16?

7) Display coins.png image that was loaded in variable I using the command:

imshow(I); then

imshow(I), impixelinfo

These commands can be used on binary, intensity, and truecolor images.

Move the cursor on the image, what is the highest value (intensity level) that you read?

8) To display indexed images, we must specify the color map along with the image data. Display the
color mapmed image trees.tif as follow:

imshow(X, map), impixelinfo

Hover your pixel on the image? What is the information provided by impixelinfo?

9) Display images side-by-side using subplot as:

subplot(1,2,2), imshow(X,map)

subplot(1,2,1), imshow(X_gray)

10) Let save the RGB image X_rgb as ‘rgb_trees.jpg’ using the following command:

imwrite(X_rgb, ‘rgb_trees.jpg’);

Go to your Documents/MATLAB folder to check on the newly save file.

NEXT: Work on your Lab 1 Assignment

You might also like