---------------------------------------------------------------------
I don't think it can translate m code into c++.
You can do tha same as mat2gray just by subtracting the min value,
dividing by the range (max-min) and multiplying by 255 and then
casting to uint8
m8 = (m - maxValue) * 255 / (maxValue - minValue);