Three histograms, three different colours, one figure: matlab -
i'm trying plot frequencies of different colour pixels in image. can draw 3 separate histograms on 3 separate figures, i'd draw them on same figure, reddish red, greenish green etc. can tell answers on , other sites, next should work, doesn't, sec appears. doing wrong?
hold on; x = 0:1:255; figure ('name', 'red') ; reddish = (newimg(:,:,1)); r = red(:)'; r = cast(r,'double'); [graph1,graph2] = hist (r,x); bar(graph2,graph1, 'facecolor', 'r','edgecolor','r') alpha(0.3); greenish = (newimg(:,:,2)); g = green(:)'; g = cast(g,'double'); [graph1,graph2] = hist (g,x); bar(graph2,graph1, 'facecolor', 'b','edgecolor','b') hold off;
you can plot histograms (rgb channels) in simpler way, example:
hist(reshape(newimg,[],3),x); colormap([1 0 0 ; 0 1 0; 0 0 1]); %rgb
here reshape newimg
nx3 matrix, equivalent [r; g ;b]
created. single hist
can process them, , using custom color map, draws each channel right color represents.
matlab histogram
No comments:
Post a Comment