(-209:Sizes of input arguments do not match) The operation is neither ‘array op array‘ (where arrays

(-209:Sizes of input arguments do not match) The operation is neither ‘array op array‘ (where arrays
在利用cv自带的加减乘除对两张图片像素进行操作时,因为其运算原理是通过获取两张(一次只能是两张)图片的同一个位置的色素值来实现运算,所以必须保证两张图片的shape相同。不然会出现以下报错:
error: (-209: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 function ‘cv::arithm_op’
解决方法:找到两张相同shape的图片进行操作,如果不知道两张图片shape是否相同,可以调用:
src1 = cv.imread(“L.jpg”)
print(src1.shape)
进行查看比对。