% imagehist2D % usage: imagehist2D(pic) or % read a jpeg image and split into three RGB components % and show the 2-compoent histograms % pic is the name of a jpg file given in 'filename.jpg' format % typically the component images will be returned as matrices of byte-sized unsigned integers % allowing 256 levels for each colour, i.e., 24 bit colour % Rmap, Gmap and Bmap are colormaps for showing the R,G,B components function imagehist2D(pic,numbins); % load picture [R,G,B,Rmap,Gmap,Bmap] = jpg2rgb(pic,'nopic'); Z = zeros(size(R)); mc = double(max([R(:);G(:);B(:)])); % show images figure(1) clf imshow(cat(3,R,G,B)); pause figure(2) clf subplot(2,3,1) imshow(cat(3,Z,G,B)); xlabel('GREEN-BLUE') subplot(2,3,4) hGB = hist2D(double(G(:)),double(B(:)),numbins,numbins); imshow(hGB,[]); xlabel ('green -->>') ylabel ('blue -->>') pause subplot(2,3,2) imshow(cat(3,R,Z,B)); xlabel('RED-BLUE') subplot(2,3,5) hRB = hist2D(double(R(:)),double(B(:)),numbins,numbins); imshow(hRB,[]); xlabel ('red -->>') ylabel ('blue -->>') pause subplot(2,3,3) imshow(cat(3,R,G,Z)); xlabel('RED-GREEN') subplot(2,3,6) hRG = hist2D(double(R(:)),double(G(:)),numbins,numbins); imshow(hRG,[]); xlabel ('red -->>') ylabel ('green -->>')