变换读取

a=imread('c:/boat.png');
b=a(:);
[k,l]=size(a);
[y0,i0]=sort(b);
m=k*l;

for i=1:m
        y1(i0(i))=y0(i);
end

w=1;
for i=1:256
    for j=1:256
        c(j,i)=y1(w);
        w=w+1;
    end
end

figure;
imshow(c,[]);

你可能感兴趣的:(c)