I'd like to plot color image histograms that combine color as RGB

24 次查看(过去 30 天)
I'd like to plot a histogram of color images that look like this
when each color band overlaps it change colors according to the RGB combination of it. Like Red-Green overlapped area produces Yellow, Green-Blue produces Cyan etc.
Thank you in advance.

回答(1 个)

Adam Danz
Adam Danz 2020-8-5
编辑:Adam Danz 2020-8-5
By setting transparency to a value less than 1, overlapping histograms will show the combined colors. However, since the histogram colors are transparent, they aren't truely red, blue, and green and therefore the color combinations won't be truely yellow and cyan.
gaus = @(x,mu,sig,amp,vo)amp*exp(-(((x-mu).^2)/(2*sig.^2)));
x = 1:100;
g1 = gaus(x,10,5,10);
g2 = gaus(x,28,5,12);
g3 = gaus(x,43,11,7);
figure()
hold on
bins = 0:100;
h(1) = histogram('BinEdges',bins,'BinCounts',g1, 'FaceColor', 'b');
h(2) = histogram('BinEdges',bins,'BinCounts',g2, 'FaceColor', 'g');
h(3) = histogram('BinEdges',bins,'BinCounts',g3, 'FaceColor', 'r');
The transparency levels can be changed using
set(h,'FaceAlpha',.4) % 0=completely transparent, 1=opaque
Of course you could compute the individual bar positions (histcounts) and which ones overlap in order to plot the overlapping and non-overlapping regions individually. Then you could set the colors of overlapping and non-overlapping regions independently.
  2 个评论
Adam Danz
Adam Danz 2020-8-6
编辑:Adam Danz 2020-8-10
Yes, my first paragraph tells you why it isn't exactly what you wanted.
My last paragraph tells you how to get exactly what you want but it will take some work.
The answer shows the best alternative.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by