???使用==>时出错加整数只能与相同类别的整数或标量双精度数组合 [英] ??? Error using ==> plus Integers can only be combined with integers of the same class, or scalar doubles

查看:467
本文介绍了???使用==>时出错加整数只能与相同类别的整数或标量双精度数组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这是我的代码:

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)转换为两倍:

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

t = double(im) + x;

这篇关于???使用==>时出错加整数只能与相同类别的整数或标量双精度数组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆