bboxresize
Resize bounding boxes
Description
Examples
Resize Image and Corresponding Bounding Boxes
Read an image.
I = imread('peppers.png');
Define bounding boxes and labels.
bboxA = [ 410 230 100 90 186 78 80 60 ]
bboxA = 2×4
410 230 100 90
186 78 80 60
labelsA = [ "garlic" "onion" ];
Resize the image and the bounding boxes.
scale = 1.5; J = imresize(I,scale); bboxB = bboxresize(bboxA,scale);
Display the results.
figure I = insertObjectAnnotation(I,'Rectangle',bboxA,labelsA); J = insertObjectAnnotation(J,'Rectangle',bboxB,labelsA); imshowpair(I,J,'montage')
Input Arguments
bboxA
— Bounding boxes
M-by-4 matrix | M-by-5 matrix | M-by-9 matrix | nonsparse numeric
Bounding boxes, specified as an M-by-4, M-by-5, or M-by-9 nonsparse numeric matrix of M bounding boxes. Each row, M, of the matrix defines a bounding box as either an axis-aligned rectangle, a rotate rectangle, or a cuboid. The table below describes the format of the bounding boxes.
Bounding Box | Description |
---|---|
Axis-aligned rectangle |
Defined in spatial coordinates as an M-by-4 numeric matrix with rows of the form [x y w h], where:
|
Rotated rectangle |
Defined in spatial coordinates as an M-by-5 numeric matrix with rows of the form [xctr yctr xlen ylen yaw], where:
|
Cuboid |
Defined in spatial coordinates as an M-by-9 numeric matrix with rows of the form [xctr yctr zctr xlen ylen zlen xrot yrot zrot], where:
The figure shows how these values determine the position of a cuboid. |
scale
— Scale
scalar (default) | row vector
Scale, specified as a scalar or a row vector. When you specify a scalar, the
function applies the same scale factor to the height and width of the bounding boxes in
bboxA
. When you specify a row vector, the function applies the
factor in the first element of the vector to resize the height and the second element to
resize the width of the bounding boxes.
Output Arguments
bboxB
— Warped bounding boxes
M2-by-N matrix | nonsparse numeric
Warped bounding boxes, returned as an M2-by-N
matrix of M2 bounding boxes. The number of bounding boxes returned is
less than the number of bounding boxes in the input. Each row, M2, of
the matrix defines one bounding box of the same type as the input
bboxA
. When bboxB
contains floating point
data, the function returns it with the same type as bboxA
.
Otherwise, the function returns bboxB
as type
single
.
Version History
Introduced in R2019bR2022a: Bounding Box Coordinates: Data augmentation for object detection using spatial coordinates
The bboxresize
,
bboxcrop
,
bboxwarp
, and
showShape
functions assume the input bounding box coordinates for axis-aligned rectangles are
specified in spatial coordinates and return the transformed bounding boxes in spatial
coordinates.
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)