MATLAB: How to get only the width and height

bounding boxmatrix array

I have a set a minimum width = 300 and height = 300 for the bounding box. I need to compare the width and height that is above 300. But right now, I am unable to compare them as I could not return the width or height values in each row. May I know how can I achieve that? Thanks.
bbox =
1174 557 63 66
1692 1517 74 78
1157 467 69 73
1123 1447 72 77
887 1572 77 82
1586 1275 93 100
1589 1517 89 95
706 1300 115 122
540 1309 122 130
496 1718 1262 1342

Best Answer

To get the overall bounding box:
bbox = [
1174 557 63 66
1692 1517 74 78
1157 467 69 73
1123 1447 72 77
887 1572 77 82
1586 1275 93 100
1589 1517 89 95
706 1300 115 122
540 1309 122 130
496 1718 1262 1342]
% Find the xRight columns
xRight = bbox(:, 1) + bbox(:, 3)
% Find the yBottom rows
yBottom = bbox(:, 2) + bbox(:, 4)
% Find the overall left-most x value
xLeft = min(bbox(:, 1))
% Find the overall right-most x value

xRight = max(xRight)
% Find the overall top-most y value
yTop = min(bbox(:, 2))
% Find the overall right-most x value
yBottom = max(yBottom)
% Get the overall bounding box
overallBox = [xLeft, yTop, xRight-xLeft, yBottom-yTop]
% Plot the individual boxes
for row = 1 : size(bbox, 1)
rectangle('Position', bbox(row, :), 'EdgeColor', 'b', 'LineWidth', 2);
hold on;
end
% Plot the overall bounding box in red.
rectangle('Position', overallBox, 'EdgeColor', 'r', 'LineStyle', '--', 'LineWidth', 2);
axis equal
xlim([0,2000]);
ylim([0,3500]);