How can I make diagram with different color at corner which fill triangle also also a scale bar showing range of value?

조회 수: 2 (최근 30일)
How can I make a triangle with three end values are 3, 4 and 5 and within show color supposing first upper corner having value 3 will show blue, lower left corner having value 4 will show red and last lower right corner will show yellow and a scale at left/right side showing values from 3-5

답변 (1개)

Image Analyst
Image Analyst 2013년 8월 25일
Not sure without working on it a bit but I'd say off the top of my head that it will probably involve roifill(). You might also have to use imline, linspace, and poly2mask.
  댓글 수: 1
Image Analyst
Image Analyst 2013년 8월 25일
Why don't you start with this code:
width = 300; % pixels.
h = linspace(0, 0.7, width);
h = repmat(h, [width, 1]);
s = ones(width,width);
v = 0.95 * ones(width,width);
hsv = cat(3, h, s, v);
rgbImage = uint8(255*hsv2rgb(hsv));
rgbImage = imrotate(rgbImage, 135);
imshow(rgbImage)
axis on
You can also try making a grayscale ramp and use ind2rgb:
grayRamp = linspace(0, 255, width);
grayRamp = repmat(grayRamp, [width, 1]);
grayRamp = uint8(imrotate(grayRamp, -45));
% Convert to color
rgbImage = ind2rgb(grayRamp, jet(256));
figure;
imshow(rgbImage);
I've given you a good start. See if you can finish it using poly2mask() to create a triangular mask and then do an element by element multiplication to zero out outside of the triangle. A smart beginning engineer like you should be able to.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by