Question

Read the MATLAB image “coins.png”, convert it to grayscale using rgb2gray(img), and then binarize it with...

Read the MATLAB image “coins.png”, convert it to grayscale using rgb2gray(img), and then binarize it with the threshold value 0.5765. Now, extend your MATLAB code to find the internal boundary by erosion: A – (A ⊖ B).
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Since coins.png is already a logical uint8 image...hence rgb to gray scale conversion is not required.

Apart from the threshold which is mentioned in the question I have used an another threshold value which gives perfect boundary detection results..

1. With Given Threshold of 0.5765

Code:

clc;clear all;close all;
f=imread('coins.png'); % Reading the coins image
f2=im2bw(f,0.5765); % binarizing the input image with given threshold
figure,imshow(f2);title('Binarized Image');
%% ------ Erosion and Boundary Estimation ---------------
se=strel('disk',3); % defining the structuring element
f3=imerode(f2,se); % erosion with structuring element disk
f4=f2-f3; % estimating Inner Boundary
figure,imshow(f4);
title('Internal Boundaries with Disk of Radius 3');
%%------- Boundary Estimation with Square Structuring Element -------
se=strel('square',3); % defining the structuring element
f5=imerode(f2,se); % erosion with structuring element disk
f6=f2-f5; % estimating Inner Boundary
figure,imshow(f6);
title('Internal Boundaries with Square of Radius 3');

2. With Given Threshold of 0.31

Code:

clc;clear all;close all;

f=imread('coins.png'); % Reading the coins image
f2=im2bw(f,0.31); % binarizing the input image
figure,imshow(f2);title('Binarized Image');
%% ------ Erosion and Boundary Estimation ---------------
se=strel('disk',1); % defining the structuring element
f3=imerode(f2,se); % erosion with structuring element disk
f4=f2-f3; % estimating Inner Boundary
figure,imshow(f4);
title('Internal Boundaries with Disk of Radius 1');
%%------- Boundary Estimation with Square Structuring Element -------
se=strel('square',3); % defining the structuring element
f5=imerode(f2,se); % erosion with structuring element disk
f6=f2-f5; % estimating Inner Boundary
figure,imshow(f6);
title('Internal Boundaries with Square of Radius 3');

Add a comment
Know the answer?
Add Answer to:
Read the MATLAB image “coins.png”, convert it to grayscale using rgb2gray(img), and then binarize it with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT