i need help with bwboundaries function
1 view (last 30 days)
Show older comments
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/211079/INimg1.jpeg)
please help me
0 Comments
Answers (2)
karthikeyan chandrasekar
on 16 Aug 2019
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 Comments
Image Analyst
on 16 Aug 2019
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!