f=imread('xx.jpg');f=f(x:x,x:x);%你想要的区域if size(f,3) == 3 f_gray = rgb2gray(f);else f_gray = f;endIx= f_gray;Value=unique(Ix(:));Count=[hist(Ix(:),Value)]';figure,plot(Value,Count);