Convert a matrix to an intensity image.
The returned matrix I is a grayscale image, of double class and in the range of values [0, 1]. The optional arguments min and max will set the limits of the conversion; values in M below min and above max will be set to 0 and 1 on I respectively.
max and min default to the maximum and minimum values of M.
If min is larger than max, the ‘inverse’ will be returned. Values in M above max will be set to 0 while the ones below min will be set to 1.
Caution: For compatibility with MATLAB, if min and max are equal (either from being actually being set manually or automatically calculated from the M min and max values, Octave’s mat2gray will truncate all values between [0 1]. For example
mat2gray ([-2 0 0.5 0.9 5], [2 2]) ⇒ [0 0 0.5 0.9 1] mat2gray ([0.5 0.5 0.5]) ⇒ [0.5 0.5 0.5] mat2gray ([4 4 4]) ⇒ [1 1 1]
See also: gray2ind, ind2gray, rgb2gray, im2double, im2uin16, im2uint8, im2int16.
Package: image