What does the below line illustrate in finding bounding box coordinates?

1 view (last 30 days)
I have obtained the code for finding the coordinates of bounding box.I could'nt understand the logic behind the code.Can anyone help me in understanding it?
I have attached the code.Please help me in understanding the code.
% // Calculate top left corner
topLeftCoords = bboxCoords(:,1:2);
% // Calculate top right corner
topRightCoords = [topLeftCoords(:,1) + bboxCoords(:,3) topLeftCoords(:,2)];
% // Calculate bottom left corner
bottomLeftCoords = [topLeftCoords(:,1) topLeftCoords(:,2) + bboxCoords(:,4)];
% // Calculate bottom right corner
bottomRightCoords = [topLeftCoords(:,1) + bboxCoords(:,3) ...
topLeftCoords(:,2) + bboxCoords(:,4)];
% // Calculating the minimum and maximum X and Y values
finalCoords = [topLeftCoords; topRightCoords; bottomLeftCoords; bottomRightCoords];

Accepted Answer

Image Analyst
Image Analyst on 10 Feb 2019
The form for the bounding box is [xLeft, yTop, width, height].
So to get the x on the right, you do
xRight = xLeft + width;
To get the y on the bottom row, you do
yBottom = yTop + height;
Knowing that you can get the (x,y) coordinates of any corner in the box.
  3 Comments
Image Analyst
Image Analyst on 10 Feb 2019
Like I said, they're in the bounding box array - whatever you used to construct bboxCoords. Let's say you called it bbox
xLeft = bbox(1);
yTop = bbox(2);
width = bbox(3);
height = bbox(4);

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!