function PlotColorFreq()
% Displays the distributions of red, green, and blue pixel values
% of a jpeg image in the current working directory, e.g.,
A = imread('Cornell_Clock.jpg');
[m,n,p] = size(A)
% These are "count vectors". For example, nRed(50) will be used to count
% the number of pixels in the image that have red value equal to 49.
nRed = zeros(1,256);
nGreen = zeros(1,256);
nBlue = zeros(1,256);
for i=1:m
for j=1:n
% Tabulate the values associated with pixel (i,j)...
r = A(i,j,1); nRed(r+1) = nRed(r+1)+1;
g = A(i,j,2); nGreen(g+1) = nGreen(g+1)+1;
b = A(i,j,3); nBlue(b+1) = nBlue(b+1)+1;
end
end
% Display...
close all
subplot(3,1,1)
plot(nRed)
title('red values')
subplot(3,1,2)
plot(nGreen)
title('green values')
subplot(3,1,3)
plot(nBlue)
title('blue values')
shg