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)

```
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');

```
%Difference between binary image and Eroded image
```
figure,imshow(D-F);title('Boundary extracted Image');

Example 2:

```
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');

## 4 comments:

I like the extraction of objects using bwlabel. Really I am searching for this for the past 4 months and got this. It is very useful and great.

Thanks a lot

how to write Matlab code to separate to perform texture segmentation based on morphology.

hai is there any code for radial undistortion in matlab or pls give a procedure for doing radial undistortion in matlab

If any body having the matlab code for extraction of roads using any algoritm or methpd please mail to me! mailid:sndp0472@gmail.com

## Enjoyed Reading? Share Your Views