Making Triangle in matlab

14 次查看(过去 30 天)
Wahab Ahmad
Wahab Ahmad 2020-4-30
How do I make the triangle without plotting function like that?

回答(2 个)

KSSV
KSSV 2020-4-30
m = 100;
n = 2*m;
I = zeros(m,n) ;
for i = 1:m-1
idx = (n/2-i):(n/2+i) ;
I(i,idx)= 1 ;
end
imshow(I)
  5 个评论
Wahab Ahmad
Wahab Ahmad 2020-4-30
That code is not works
KSSV
KSSV 2020-4-30
Why it not work? You have to change vertices accordingly.

请先登录,再进行评论。


Image Analyst
Image Analyst 2022-7-18
You can use poly2mask
x = [100, 200, 300]; % Left vertex, top vertex, right vertex.
y = [300, 100, 300]; % Left vertex, top vertex, right vertex.
mask = poly2mask(x, y, 400, 400);
imshow(mask);
axis on

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by