Unable to draw just the boundary of an image

1 view (last 30 days)
Hi,
I want to draw just the boundary of a ROI. segFP1.jpg is the original image. I applied the code below but I don't get the desired result. My result is displayed in e1.jpg. Any suggestions would be appreciated. Thank you.
I=imread('segFP1.jpg');
figure,imshow(I)
I1=bwperim(I,8);
figure,imshow(I1)

Accepted Answer

DGM
DGM on 19 Jul 2021
Edited: DGM on 19 Jul 2021
Well, you're loading a grayscale image subject to destructive compression as a jpg file. At no point do you explicitly threshold the image, so it's probably just getting thresholded at I>0, and so a bunch of compression artifacts are part of the binarized image.
I=imread('segFP1.jpg'); % this is not a binary image
I = I>128; % threshold it somewhere
I1=bwperim(I,8); % otherwise this will
subplot(2,1,1)
imshow(I)
subplot(2,1,2)
imshow(I1)
  3 Comments
Warid Islam
Warid Islam on 19 Jul 2021
Hi @DGM,
That worked perfectly. Thanks a lot.

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!