Making Triangle in matlab
Ältere Kommentare anzeigen
How do I make the triangle without plotting function like that?

Antworten (2)
KSSV
am 30 Apr. 2020
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 Kommentare
Wahab Ahmad
am 30 Apr. 2020
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
am 30 Apr. 2020
Wahab Ahmad
am 30 Apr. 2020
KSSV
am 30 Apr. 2020
Why it not work? You have to change vertices accordingly.
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
Kategorien
Mehr zu Labels and Annotations finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

