Draw a triangle in image knowing its center of gravity
Show older comments
i need to draw a white triangle in a black image. So the first idea that i had got is to define the three peaks that define the triangle and then recuperate the points that belong to its surface. and then affect the value 1 to these points in a black image. To recuperate the points belong to the surface of the triangle i write this code which reflects the idea that a point belongs to a plan it verifies an equation system like after: ( the plane will be the triangle)
if true
k=1;
for i=1:size_image_x
for j=1:size_image_y
equation_x=i-x_peak1==xk*(x_peak2-x_peak1)+yk*(x_peak3-x_peak1);
equation_y=j-y_peak1==xk*(y_peak2-y_peak1)+yk*(y_peak3-y_peak1);
eqx=solve(equation_x,xk,yk);
eqy=solve(equation_y,xk,yk);
if isempty(eqx)~=1 && isempty(eqy)~=1
point_x(1,k)=i;
point_y(1,k)=j;
k=k+1;
end
end
end
end
but it doesn't work
may any one help me please
thanks
Accepted Answer
More Answers (0)
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!