基于python的图像运算(算术)

2025-04-12 03:05:43

1、图像加载:img=cv2.imread('a.png')进行乘法运算:a = 坡纠课柩img*2

基于python的图像运算(算术)

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

基于python的图像运算(算术)

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

基于python的图像运算(算术)
基于python的图像运算(算术)

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

基于python的图像运算(算术)

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

基于python的图像运算(算术)

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

基于python的图像运算(算术)

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

基于python的图像运算(算术)

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

基于python的图像运算(算术)

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

基于python的图像运算(算术)
基于python的图像运算(算术)
基于python的图像运算(算术)
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢