MATLAB Answers

How to get height and width of region enclosed in the boundaries for use with bwboundaries?

3 views (last 30 days)
Ravindra Nadekar
Ravindra Nadekar on 27 Oct 2018
Edited: Matt J on 27 Oct 2018
clc;
clear;
I = imread('../demo.jpg');
imshow(I)
grayImage = rgb2gray(I);
BW = im2bw(I);
imshow(BW)
hold on;
boundaries = bwboundaries(BW);[enter image description here][1]
fprintf('length values is = %i\n ',length(boundaries));
for k=14:14
b = boundaries{k};
fprintf('b values is = %i\n ',b);
img = plot(b(:,2),b(:,1),'r','LineWidth',3);
end

  0 Comments

Sign in to comment.

Accepted Answer

Matt J
Matt J on 27 Oct 2018
Edited: Matt J on 27 Oct 2018
Using regionprops(...,'BoundingBox'), will give the location, height, and width of the bounding box for each of the objects in the image.

  0 Comments

Sign in to comment.

More Answers (0)


Translated by