LAB#3
LAB#3
Objective:
The objective of this lab to perform connected component labelling in images and to get an
understanding of distance maps and intensity level resolution.
Theory:
Connected Component Analysis or Labelling enables us to detect different objects from a binary
image. Once different objects have been detected, we can perform a number of operations on
them: from counting the number of total objects to counting the number of objects that are similar,
from finding out the biggest object of the bunch to finding out the smallest and from finding out
the closest pair of objects to finding out the farthest etc. Connected Component labelling
procedure is as follows:
Intensity level resolution defines the resolution at bit level i.e. how many bits are used to represent
a pixel value. The more bits we have per pixel, the more levels there are. For example, a grayscale
image has 256 different levels because for each pixel value we use 8 bits to store the value. If the
bits per pixel are decreased to 4, then the maximum levels that we can have is 16. Similarly, if
only 1 bit is used for it then we can have only two levels (or a binary image). To change the bit
level resolution, different levels (or intensities) can be grouped together to form new levels. For
example, for a 3 bits/pixel image:
0 1 2 3 4 5 6 7
0 1 2 3
0 1
Some Useful Commands:
Lab Tasks:
Lab Task 1:
Read a grayscale image (given below) and convert the image to 16 levels, then to 4 levels and
finally to 1. Display all four images.
Lab Task 2:
Create an empty image of zeros of size 501x501 and then create a distance map by calculating the
Euclidian Distance of every pixel from the center. Display the distance map. (Don’t forget to declare
the data type of the array of zeros as uint8).
Lab Task 3:
For the image given above (also available with the lab handout), apply the connectected
component labelling using 4 connectivity and count the total number of objects in the lsit. (HINT:
In the image given here, the background (black portion) has a numeric value of 1 while the white
objects have a numeric value of 255.)