Convert matrix to grayscale image
I = mat2gray(A, [amin amax])
I = mat2gray(A)
gpuarrayI = mat2gray(gpuarrayA,___)
I = mat2gray(A, [amin amax]) converts the matrix A to the intensity image I. The returned matrix I contains values in the range 0.0 (black) to 1.0 (full intensity or white). amin and amax are the values in A that correspond to 0.0 and 1.0 in I. Values less than amin become 0.0, and values greater than amax become 1.0.
The input array A can be logical or numeric. The output image I is double.
The input gpuArray gpuarrayA can be logical or numeric. The output gpuArray image gpuarrayI is double.
Read an image and, for this example, turn it into a numeric matrix.
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)