i need help with bwboundaries function
2 次查看(过去 30 天)
显示 更早的评论
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."
please help me
0 个评论
回答(2 个)
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.
0 个评论
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);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!