MATLAB Answers

Cesar
0

Create a triangular image with height of 200 pixels and the base of 200 pixels and color the image in any two colors.

Asked by Cesar
on 13 Feb 2013

Create a triangular image with height of 200 pixels and the base of 200 pixels and color the image in any two colors.

  0 Comments

1 Answer

Answer by Image Analyst
on 13 Feb 2013

Hint: use poly2mask() and logical indexing.

yourImage = zeros(rows, columns, 'uint8'); % Initialize.
% Assign values to triangle defined by "mask" image.
yourImage(mask) = someValue; 

  30 Comments

Well I think I will not solve it (supposedly I don't know how). I did way too much already, and it's such a trivial chore to finish it. Like Walter and I said, just do it twice. You said that half the triangle was one color and the other half was a different color. Now, ask yourself "What shape is half a triangle?" But ultimately it's your problem, not ours, and we should not do 100% of it for you, and I won't. There needs to be some part of it that you own, that you write yourself. You have all the tools, so, good luck with that.

Using fill(X,Y,C). The fill function creates colored polygons.


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!