How do I make the triangle without plotting function like that?

답변 (2개)

KSSV
KSSV 2020년 4월 30일

0 개 추천

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일
acutally i want this thing you work is good but when i want this nearest size of this triangle
KSSV
KSSV 2020년 4월 30일
편집: KSSV 2020년 4월 30일
This is more simple buddy.....get the three vertices you want, use inpolygon and change the values.
Example:
m = 100 ;
n = 100 ;
[X,Y] = meshgrid(1:m,1:n) ;
A = [47 77] ;
B = [25 35] ;
C = [25 70] ;
P = [ A; B; C; A] ;
idx = inpolygon(X,Y,P(:,1),P(:,2))
Wahab Ahmad
Wahab Ahmad 2020년 4월 30일
Thats the only code i have to run and get this figure
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일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품

질문:

2020년 4월 30일

답변:

2022년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by