OpenCV Error: Sizes of input arguments do not match (The operation is neither
'array op array' (where arrays have the same size and the same number of channels),
nor 'array op scalar', nor 'scalar op array') in arithm_op, file /home/lzm/opencv-3.4.0/modules/core/src/arithm.cpp, line 659
terminate called after throwing an instance of 'cv::Exception'
what(): /home/lzm/opencv-3.4.0/modules/core/src/arithm.cpp:659: error: (-209)
The operation is neither 'array op array' (where arrays have the same size and the
same number of channels), nor 'array op scalar', nor 'scalar op array' in function
arithm_op
已放弃 (核心已转储)
如果您向我们展示更多代码,我们可以尝试提供更多详细信息,否则@Barriel答案是可以的。还要注意 addWieighted
用 alpha = 1
, beta = 1
并且 gamma = 0
是两个图像的简单相加: temp_image += noise_image;
。无论如何,要注意饱和度。 - Miki 2015年9月29日11:05
您需要确保 temp_image
并 noise_image
具有相同的 大小 和 频道编号。通常,当其中一个图像出现BGR
而另一个出现 时,就会发生这种情况 GRAY
。
也就是说两张图片应该有相同的大小和rgb类型即可