Reputation: 2454
For this picture:
EDIT:
1: I did that:
a = imread('C:\a.jpg');
r = a(:,:,1);
g = a(:,:,2);
b = a(:,:,3);
rhist = zeros(1,256);
[w h] = size(a(:,:,1));
for i=1:w
for j=1:h
rhist(r(i,j)+1) = rhist(r(i,j)+1)+1;
end
end
rhist(x) is count of red intensity that is equal to x-1
Now I just need a little help how to draw this data as a histogram
2: Still, have no idea :(. I'm using im2bw with different second argument but that does not help.
I'm guessing that some blur might help?
3: No idea, too.
Upvotes: 1
Views: 2556
Reputation: 124563
Here is my version of IMHIST:
I = imread('pic.jpg');
II = double(I);
clr = 'rgb'; clrTxt = {'Red' 'Green' 'Blue'};
for i=1:3
h = subplot(3,1,i);
c = histc(reshape(II(:,:,i),[],1), 0:255);
bar(0:255, c./max(c), 'histc')
set(gca, 'XLim', [0 255], 'YLim',[0 1])
set(findobj(h,'Type','patch'), 'FaceColor',clr(i), 'EdgeColor','none')
ylabel(clrTxt{i})
end
xlabel('Intensity')
Upvotes: 3
Reputation: 5714
For 1:
i = imread('fabric.png');
r = sum(sum(i(:,:,1)))
g = sum(sum(i(:,:,2)))
b = sum(sum(i(:,:,3)))
bar([r g b])
Upvotes: 0