A=imread('o.jpg'); A=im2double(A); frequency=zeros(1,511); for i=1:size(A,1) for j=1:size(A,2) frequency(A(i,j)+256)+=1; end end