www.gusucode.com > images 案例代码 matlab源码程序 > images/ConvertAMatrixIntoAnImageExample.m

    %% Convert a Matrix into an Image
% 
%%
% Read an image and, for this example, turn it into a numeric matrix.

% Copyright 2015 The MathWorks, Inc.

I = imread('rice.png');
J = filter2(fspecial('sobel'),I);
%%
%  Convert the matrix into an image.
%%
K = mat2gray(J);
%%
%  Display the original image and the result of the conversion.
%%
imshow(I), figure, imshow(K)