# How do I get only the width and height?

3 visualizaciones (últimos 30 días)
Leonard Yeo el 15 de Nov. de 2015
Editada: Leonard Yeo el 17 de Nov. de 2015
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
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

Image Analyst el 15 de Nov. de 2015
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]);
##### 3 comentariosMostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos
Leonard Yeo el 17 de Nov. de 2015
Editada: Leonard Yeo el 17 de Nov. de 2015
This is what I need! Thank you very much!

Iniciar sesión para comentar.

### Más respuestas (2)

Andrei Bobrov el 15 de Nov. de 2015
bbox(3);
##### 3 comentariosMostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos
Leonard Yeo el 15 de Nov. de 2015
Editada: Leonard Yeo el 15 de Nov. de 2015
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.
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
So if I were to put bbox(3), it only returns 1157 instead of 69.
>> bbox(3)
ans =
1157

Iniciar sesión para comentar.

Image Analyst el 15 de Nov. de 2015
Try this:
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]
% Set min width in column 3 to 300
bbox(:, 3) = max(300, bbox(:, 3))
% Set min height in column 4 to 300
bbox(:, 4) = max(300, bbox(:, 4))
The final result:
bbox =
1174 557 300 300
1692 1517 300 300
1157 467 300 300
1123 1447 300 300
887 1572 300 300
1586 1275 300 300
1589 1517 300 300
706 1300 300 300
540 1309 300 300
496 1718 1262 1342
##### 1 comentarioMostrar NingunoOcultar Ninguno
Leonard Yeo el 15 de Nov. de 2015
Hi, sorry but there will be setting the bbox width and height to 300. But, there is not the objective of it. My goal is to filter out bounding box size which are too small to be classified as an object and only put a bounding box which are of certain sizes.

Iniciar sesión para comentar.

### Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by