i need help with bwboundaries function

2 ビュー (過去 30 日間)
Bekhtaoui Abdelhakim
Bekhtaoui Abdelhakim 2019 年 3 月 29 日
回答済み: Image Analyst 2019 年 8 月 16 日
hi everyone please i need your help i did not know how to use bwboundaries and boundingbox and bwconncomp on my picture
here is the discription and the image:
"The obtained image will have a dark, thick boundary which has to be eliminated so that thinning won’t be a problem. This is done by using ‘bwboundaries’ to find the
boundary and then using ‘boundingbox’ to define the boundary. Then the maximum no of connected components (bwconncomp) is calculated and eliminated."
INimg1.jpg
please help me

回答 (2 件)

karthikeyan chandrasekar
karthikeyan chandrasekar 2019 年 8 月 16 日
Hi,
Follow this example for drawing boundaries in the image
img1 = imread('your image');
img2=im2bw(img1,graythresh(img1));
img2=~img2;
img2 = bwareaopen(img2,30);// try changing the sensitivity if not proper output
B = bwboundaries(img2,'noholes');//no holes is required in case of your image.

Image Analyst
Image Analyst 2019 年 8 月 16 日
I presume your foreground is white and background black. So just call imclearborder(). bwboundaries() and regionprops(BW, 'BoundingBox') are not needed. Then to get the number of connected components:
mask = imclearborder(mask); % Get rid of huge white surround (background).
[labeledImage, numberOfRegions] = bwlabel(mask); % Label what's left.
% Let's assign each blob a different color to visually show the user the distinct blobs.
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
% coloredLabels is an RGB image. We could have applied a colormap instead (but only with R2014b and later)
imshow(coloredLabels);
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
caption = sprintf('Pseudo colored labels, from label2rgb().\n%d Blobs are numbered from top to bottom, then from left to right.', numberOfRegions);
title(caption, 'FontSize', 15);

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by