このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。
bboxcrop
境界ボックスのトリミング
構文
説明
例
イメージおよび対応する境界ボックスの中央トリミング
イメージを読み取ります。
I = imread('peppers.png');
境界ボックスとラベルを定義します。
bboxA = [ 410 230 100 90 186 78 80 60 ]
bboxA = 2×4
410 230 100 90
186 78 80 60
labelsA = [ "garlic" "onion" ];
中央トリミング ウィンドウを作成します。
targetSize = [256 256]; win = centerCropWindow2d(size(I),targetSize);
イメージを中央でトリミングします。
[r,c] = deal(win.YLimits(1):win.YLimits(2),win.XLimits(1):win.XLimits(2)); J = I(r,c,:);
ボックスとラベルを中央でトリミングします。トリミング ウィンドウの外にあるボックスは削除されます。
[bboxB,indices] = bboxcrop(bboxA,win); labelsB = labelsA(indices);
結果を表示します。
figure I = insertObjectAnnotation(I,'Rectangle',bboxA,labelsA); J = insertObjectAnnotation(J,'Rectangle',bboxB,labelsB); imshowpair(I,J,'montage')
入力引数
bboxA
— 境界ボックス
M 行 4 列の行列 | M 行 5 列の行列 | M 行 9 列の行列
境界ボックス。M 行 4 列、M 行 5 列、または M 行 9 列の非スパース数値行列として指定します。M は境界ボックスの数です。行列の各行で、軸に平行な四角形、回転した四角形、または直方体として、境界ボックスを定義します。次の表に、各境界ボックスの形式を示します。
境界ボックス | 説明 |
---|---|
軸に平行な四角形 | [x y w h] 形式の行をもつ M 行 4 列の数値行列として、ピクセル座標で定義します。ここで、
|
回転した四角形 | [xctr yctr xlen ylen yaw] 形式の行をもつ M 行 5 列の数値行列として、空間座標で定義します。ここで、
|
直方体 | [xctr yctr zctr xlen ylen zlen xrot yrot zrot] 形式の行をもつ M 行 9 列の数値行列として、空間座標で定義します。ここで、
次の図は、これらの値で直方体の位置がどのように決定されるかを示しています。 |
threshold
— オーバーラップしきい値
1 (既定値) | 1
以下の正のスカラー
オーバーラップしきい値。1
以下の正のスカラーとして指定します。変換後のボックスと出力表示によって定義される領域とのオーバーラップ量は、次のように定義されます。
(bounding rectangle に交差する bbox 領域) / (bbox 領域)
bounding rectangle — 入力空間参照オブジェクト
ref
によって定義される。bbox —
bboxA
内のボックスの変換結果。
オーバーラップの計算値が threshold
プロパティよりも大きい場合、変換後のボックスが bounding rectangle の境界でクリップされます。そうでない場合、ボックスは破棄されます。しきい値を下げると、オブジェクトの一部が破棄されることがあります。
出力引数
バージョン履歴
参考
imcrop
| bboxresize
| bboxwarp
| bboxerase
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは 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)