You are on page 1of 3

Exercise1: Read an image eight.tif.

Write a function
named myMorphology to extract the boundaries of coins from the read image.

Solution:
M File:
function myMorphology(img) imgb=im2bw(img); imgc = imcomplement(imgb); sel = strel('disk',5); imgn = imdilate(imgc,sel); imgn1 = imerode(imgn,sel); imgn2 = imerode(imgn1,sel); fltr = fspecial('laplacian'); fltrd_img = imfilter(imgn2, fltr, 'replicate'); imshow(img), figure, imshow(fltrd_img)

Functional Call from Command Window:


>> img=imread('eight.tif'); >> myMorphology(img)

Output:

Figure 1: Original Image

Changed Image (Boundaries of Original Image):

Figure 2: Changed Image (Boundaries of Original Image)

You might also like