You are on page 1of 3

Sri Lanka Institute of Information Technology

BSc (Hons) in Engineering (EEE/CSE/EPE)


EC 247 Computing for Engineers
Laboratory 2 - Introduction to Image Analysis
Note:
Unzip the given file. Change your Matlab working directory to the folder where the unzipped items
are. Use Matlab editor to construct you code. All images you require are given in the folder.

Part I
1. Load the Image car given in the folder.

2. Convert the image to a Gray image. Observe the result.

3. Convert the original Image to Black and white and observe the result.

The thresholding value used is 0.3. It may be any value between 0 1. Change the
thresholding value and observe what happens to the black and white image.

4. On the Matlab Command window, type:

Gray_Img

Black_White

Observe the difference between the matrices.

5. Save the black and white image as a separate image.

6. Resizing an image

Change the values within square brackets. Observe what happens to the resulting
image Resized_Img

7. From the knowledge you gained from 1-5,

Convert the Resized_Img in to Gray scale and show it in a separate figure.

Convert the Resized_Img to a black & white image and show it in another figure.

Save the resized gray image & the resized black and white image as separate images.
(You may use any image format you prefer. Use Matlab help for more information on
supported image formats)

Part II
Use a separate m-file for Part II. Follow the steps given below. (Use your knowledge from Part I
if syntax is not given)
1. Load the image coins.

2. Convert the loaded image to a black and white image. (Use a suitable value for
thresholding)
3. Show the black and white image in a window : figure(1) & save the black and white
image.

4. Invert the colours of the black and white image.


An example is given below, where BW is the black and white image.

5. Show the inverted black and white image in a separate window : figure(2) and save this
image in a format you prefer.

6. Use the syntax given below and observe what happens.

7. Draw contours of an image and display it in a separate figure.

Part III Homework


1. A thresholding value was used when converting an image to black and white. Why is a
thresholding value needed? What is its importance?
2. Find out more about contours
3. Today you have taken the first step in image processing. Think of applications in which
you may find contour detection useful.

You might also like