基于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.8
a*0.0002+d*0.9998
a+d*2



声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:96
阅读量:63
阅读量:76
阅读量:170
阅读量:170