Open In App

Boundary Extraction of image using MATLAB

The boundary of the image is different from the edges in the image. Edges represent the abrupt change in pixel intensity values while the boundary of the image is the contour. As the name boundary suggests that something whose ownership changes, in the image when pixel ownership changes from one surface to another, the boundary comes into the picture. Edge is basically the boundary line but the boundary is the line or location dividing the two surfaces. 

Types of boundary extraction techniques

There are two types of boundaries in binary images.



           

What are imerode() and imdilate()?

Erosion and Dilation both are morphological operations. 



Syntax:

J = imerode(I,SE)

Syntax:

J = imdilate(I,SE)

Example 1:

% MATLAB code for INNER Boundary
% read the image.
k=imread("1.png");
 
% Convert into grayscale.
k=rgb2gray(k);
 
% Define structuring element.
SE=strel('disk',2,0);
 
% Erode the image.
k1=imerode(k,SE);
 
% Take the difference of original
% and eroded image.
k2= k-k1;
 
% Display original image.
imtool(k);
 
% Display inner boundary image.
imtool(k2);

                    

 
 

Output: 


 

Figure: Original image and Inner boundary image

figure: Original image

figure: Inner boundary image

Code Explanation:

Example 2:


 

% MATLAB code OUTER Boundary
% Read the image.
k=imread("1.png");
 
% Convert to grayscale.
k=rgb2gray(k);
 
% Define the structuring element.
SE=strel('disk',2,0);
 
% Dilate the image.
k1=imdilate(k,SE);
 
% Take the difference
k2= k1-k;
 
% Display original image.
imtool(k);
 
% Display outer boundary image.
imtool(k2);

                    

 
 

Output:


 

 figure: Original image and Outer boundary image

figure: Original image

figure: Outer boundary image


 


Article Tags :