基于python的图像运算(算术)
1、图像加载:img=cv2.imread('a.png')进行乘法运算:a = img*2

2、进行加法运算:a = img+36

3、分离色彩,也可以用乘法实现:a = img*[0,1,0]a = img*[1,1,0]


4、这样,可以加深某一种颜色,减弱另一种颜色:a = img*[0.9,3,2]

5、再准备一幅图片:img0=cv2.imread('d.png')

6、看看img和img0能不能相加:a = img+img0结果报错:ValueError: operands could not be broadcast together with shapes (572,765,3) (546,726,3)原因是两幅图片的尺寸不同。

7、把两幅图片改成一样大小:a = cv2.resize(img,(500,365),interpolation=cv2.INTER_CUBIC)d = cv2.resize(img0,(500,365),interpolation=cv2.INTER_CUBIC)

8、此时的a+d是可以实现的。

9、在a+d里面,淡化a,强化d:a*0.2+d*0.8a*0.0002+d*0.9998a+d*2


