FUNCTION REFERENCE
mat2gray
Scale a matrix to the intensity range [0, 1].
Scale a matrix to the intensity range [0, 1].
Syntax
I = mat2gray(A)Syntax
I = mat2gray(A, [amin amax])I = (A - amin) / (amax - amin), with values at or below amin set to 0 and at or above amax set to 1. The defaults are the smallest and largest values of A (NaN ignored). The result is double for every input class; NaN stays NaN.
Example
mat2gray([2 4 6 10]) % [0 0.25 0.5 1]Example
mat2gray([2 4 6 10], [4 6]) % [0 0 1 1]Differences from MATLAB: the reference page does not say what happens when amin equals amax; MatRust then returns A itself clipped to [0, 1].
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.