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
0 个评论
回答(1 个)
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
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 Center 和 File Exchange 中查找有关 Formatting and Annotation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!