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

Learn moreOpportunities for recent engineering grads.

Apply Today
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.

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;

Show 27 older comments

Image Analyst on 16 Feb 2013

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.

Cesar on 18 Feb 2013

I did solve it. This is how it should look: https://www.dropbox.com/s/gsgcsb8rqwlg55z/done.doc

## 0 Comments