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

六眼飞鱼酱① 提交于 2019-12-11 09:54:44

问题


When i'm trying to add pixel data to data created by gaussian randn() function it's spitting the error

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

This is my code:

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

回答1:


Convert the integers (uint8) from your read image im to double:

t = double(im) + x;


来源:https://stackoverflow.com/questions/33300588/error-using-plus-integers-can-only-be-combined-with-integers-of-the-same

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!