Matlab image data type conversion prompt error: Function'*' is not defined for values of class'uint8' analysis

The data type of the image read in MATLAB is uint8, and the data type used in the matrix is ​​double, so I2=im2double(I1): convert the image array I1 to double precision type; if you don’t convert, it will overflow when adding and subtracting uint8. Tip of error Function '*' is not defined for values of class 'uint8'was: .

By default:
matlab stores the data in the image as a double type, that is, a 64-bit floating point number ;

Matlab also supports unsigned integers (uint8 and uint16);

The advantage of uint type is to save space, and it needs to be converted to double type when calculation is involved.

  • im2double(): Convert image array to double precision type
  • im2uint8(): Convert the image array to unit8 type
  • im2uint16(): Convert image array to unit16 type

Note: Use im2uint8() for double type images, there will be problems.
Double defaults to a number between 0-1, uint8 is a number between 0-255, if the array uint8 type x1={0,1,2}, after conversion, it becomes x2={0,0.5,1};
if the array Double type y1={0, 1, 2}, after conversion, y2={0, 255, 255}

Guess you like

Origin blog.csdn.net/ywsydwsbn/article/details/108718823