Boundary Extraction of any object using MATLAB
Boundary Extraction in MATLAB
Let A be an Image matrix and B be a structuring element.
Formula for Boundary Extraction:
Steps to be followed:
· Convert the image into binary image.
· Perform Erosion:
Erode binary image A by structuring element B. (i.e)
Erode binary image A by structuring element B. (i.e)
· Subtraction:
Subtract the binary image A from the Eroded image.(i.e)
Subtract the binary image A from the Eroded image.(i.e)
MATLAB Code:
A=imread('banana.jpg');
C=rgb2gray(A);
C(C<225)=0;
s=strel('disk',4,0);%Structuring element
D=~im2bw(C);%binary Image
F=imerode(D,s);%Erode the image by structuring element
figure,imshow(A);title('Original Image');
figure,imshow(D);title('Binary Image');
Example:
A=imread('nutsbolts.tif');
s=strel('disk',2,0);
F=imerode(A,s);
figure,
subplot(2,1,1);
imshow(A);title('Binary Image');
subplot(2,1,2);
imshow(A-F);title('Boundary extracted Image');
No comments:
Post a Comment