検出枠の分割

3 views (last 30 days)
tsuyoshi tsunoda
tsuyoshi tsunoda on 24 Dec 2021
Commented: tsuyoshi tsunoda on 25 Dec 2021
以下のように以前、検出した枠を6分割して2コマ目と5コマ目を新しく枠として設定するといったコードを書いていたのですが、
これを「3分割して1コマ目と3コマ目を新しい枠として設定」に変更したいのですが、分からなくなってしまいました。
どなたかご教授願います。
EyeBox = [ObjBox(:,1)+ObjBox(:,3)*(1+wd*3)/6, ObjBox(:,2), ObjBox(:,3)/6, ObjBox(:,4)];

Accepted Answer

Shunichi Kusano
Shunichi Kusano on 24 Dec 2021
一気にやろうとすると頭がこんがらがってくるので、おススメのやり方は、配列の要素を1つずつ取り出してわかりやすい変数名で置き換えて、一ステップずつ考えるといいと思います。
x0 = ObjBox(:,1); % 左上のX座標
y0 = ObjBox(:,2); % 左上のY座標
w = ObjBox(:,3); % widthの頭文字
h = ObjBox(:,4); % heightの頭文字
% 3分割した枠の定義
w3 = round(w/3); % X方向に3分割した場合の1個当たりの枠のwidth
EyeBox1 = [x0,y0,w3,h];
CenterBox = [x0+w3,y0,w3,h];
EyeBox2 = [x0+w3*2,y0,w3,h];
  1 Comment
tsuyoshi tsunoda
tsuyoshi tsunoda on 25 Dec 2021
回答ありがとうございます。教えていただいた事を理解でき、一文でも書くことが出来ました。

Sign in to comment.

More Answers (0)

Categories

Find more on 文字と文字列 in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!