フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Create matrix of rectangular ones

2 ビュー (過去 30 日間)
LM
LM 2021 年 7 月 1 日
閉鎖済み: Stephen23 2021 年 7 月 1 日
I wrote a script that creates a 248x286 matrix of zeros with rectangular verticle bars of varying widths and element values 255. I would like to make 9 rectangular bars in the north, south, east, west and center locations. The script works for one set of bars but it is not well-written. I would appreciate help to optimize my program below. Thank you.
A = zeros(248,286); %create matrix of zeros
A(20:60,124:134) = 1 %north: rectangles 40 pixels long and 10 pixels wide
A(20:60,144:154) = 1
A(20:60,164:174) = 1
A(70:120,124:130) = 1 %north: rectangles 40 pixels long and 6 pixels wide
A(70:120,140:146) = 1
A(70:120,156:160) = 1
A(130:170,124:126) = 1 %north: rectangles 40 pixels long and 2 pixels wide
A(130:170,136:138) = 1
A(130:170,148:150) = 1
m = A*255;
imshow(m)
imwrite(m, 'Verticle_bars.bmp')

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by