??? Error using ==> plus Integers can only be combined with integers of the same class, 或者标量双精度数

??? Error using ==> plus Integers can only be combined with integers of the same class, or scalar doubles

当我尝试将像素数据添加到由高斯 randn() 函数创建的数据时,出现错误

??? Error using ==> plus Integers can only be combined with integers of the same class, or scalar doubles.

这是我的代码:

im = imread( 'ngc6543a.jpg' );   % matlab example image
x  = randn( size (im) );         % create gaussian distributed values
t  = im + x;                     % add them together, this throws the error

将读取的图像 im 中的整数 (uint8) 转换为双精度数:

t = double(im) + x;