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!