用matlab做出灰度图像的灰度直方图

2019-04-15 13:37发布

pic=imread('1.jpg');
data=rgb2gray(pic);
figure;imshow(data);
num=ones(1,256);
for i=0:255
temp=find(data==i);
num(i+1)=length(temp);
end
k=0:255;
subplot(121)
stem(k,num);
axis([0 255 0 max(num)+100]);
subplot(122)
imhist(data);