Triangular Pyramid Image and Color it
Show older comments
Please Can Somebody tell me how to generate a triangular Pyramid image of 2 by 2 with height of 200 pixels and the base of 200 pixels; and Color the image in any two colors "http://www.google.com/imgres?q=triangular+Pyramid+image+of+2+by+2&hl=en&tbo=d&biw=1366&bih=541&tbm=isch&tbnid=hhxBKdNeShxfdM:&imgrefurl=http://www.analyzemath.com/calculus/Integrals/volume_square_pyramid.html&docid=Ts_z5lT0xhYuyM&imgurl=http://www.analyzemath.com/calculus/Integrals/volume_square_pyramid_2.gif&w=322&h=312&ei=j0O6UKCyKPCB0QHk_YH4CA&zoom=1&iact=hc&vpx=935&vpy=179&dur=12880&hovh=221&hovw=228&tx=102&ty=244&sig=116099075241339748532&page=1&tbnh=141&tbnw=150&start=0&ndsp=22&ved=1t:429,r:20,s:0,i:147" THIS IS AN EXAMPLE OF 2 BY 2 TRIANGULAR PYRAMID THAT I'M TALKING ABOUT. I would like to have codes that imshow a triangular Pyramid Image and color each with two diferent color such as Blue and Red. Can somebody do that.
7 Comments
Image Analyst
on 1 Dec 2012
What does 2 by 2 mean? You mean a really really small quantized rectangle of 2 by 2 at the center of a 200 x 200 square image? That's not really a triangle. It's just some pixels like
0 255
255 255
only 3 pixels!
Walter Roberta
on 1 Dec 2012
Image Analyst
on 1 Dec 2012
That explanation does not help at all. I still don't know what 2 by 2 means. 2 what by 2 what? Pixels? Can you try to draw the values like I did. And I'm not sure what code you copied to MATLAB. The stuff above was not code - just pixel values. And the code in my answer below draws a triangle just fine.
Image Analyst
on 1 Dec 2012
Oh! Do you mean you want two complete rectangles side-by-side? If so, I gave you code for one triangle below. All you have to do is repeat it with different vertices. Simple.
Walter Roberta
on 1 Dec 2012
Walter Roberta
on 1 Dec 2012
Image Analyst
on 1 Dec 2012
Like I said: I gave you code for one triangle below. All you have to do is repeat it with different vertices. Simple. Just change x and y. Surely you can do that. It's so trivial that I'm not going to do it for you.
Answers (1)
Image Analyst
on 1 Dec 2012
Edited: Image Analyst
on 1 Dec 2012
I showed you the concepts in this solution so it should not be too hard for you to adapt that. If you want to do it a different way than I did it for you there, you might look into poly2mask(), if you have the Image Processing Toolbox. In fact that's a much easier way since you have triangles.
Alright - haven't heard back from you so I guess you need more help.
x = [100 150 50];
y = [50 150 150];
redChannel = 255 * poly2mask(x, y, 200, 200);
greenChannel = 255 * ones(200);
blueChannel = zeros(200);
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
imshow(rgbImage);
axis on;
axis square;
axis image;
2 Comments
Cesar
on 15 Feb 2013
yes more help
Image Analyst
on 15 Feb 2013
Do you have the same assignment at Walter Roberta? Cesar, I gave you the entire solution to your assignment in http://www.mathworks.com/matlabcentral/answers/63312#comment_129804. Unfortunately you can't now turn it in as your homework because I did it all for you.
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!