Computergbhistogram
Computergbhistogram
m 1 of 1
function H=ComputeRGBHistogram(img,Q)
% INPUT: img, an RGB image where pixels have RGB values in range 0-255
% INPUT: Q, the level of quantization of the RGB space e.g. 4
% First, create qimg, an image where RGB are normalised in range 0 to (Q-1)
% We do this by dividing each pixel value by 256 (to give range 0 - just
% under 1) and then multiply this by Q, then drop the decimal point.
qimg=double(img)./256;
qimg=floor(qimg.*Q);
% Now, create a single integer value for each pixel that summarises the
% RGB value. We will use this as the bin index in the histogram.
vals=reshape(bin,1,size(bin,1)*size(bin,2));
H = hist(vals,Q^3);
H = H ./sum(H);