i need help with bwboundaries function

8 Ansichten (letzte 30 Tage)
Bekhtaoui Abdelhakim
Bekhtaoui Abdelhakim am 29 Mär. 2019
Beantwortet: Image Analyst am 16 Aug. 2019
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

Antworten (2)

karthikeyan chandrasekar
karthikeyan chandrasekar am 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.

Image Analyst
Image Analyst am 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);

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by