将坐标的图片变成右边效果。
原理非常简单,提取出R,G,B层,错位叠在一起。
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
_ , axes= plt.subplots(2,3)
douyin=Image.open("logo.png").convert("RGB")
width,hight=douyin.size
array_r=np.array(douyin)
array_r[:, :, 1] = 0
array_r[:, :, 2] = 0
douyin_r=Image.fromarray(array_r)
array_g = np.array(douyin)
array_g[:, :, 0] = 0
array_g[:, :, 2] = 0
array_b = np.array(douyin)
array_b[:, :, 0] = 0
array_b[:, :, 1] = 0
array_gb=array_g+array_b
douyin_gb=Image.fromarray(array_gb)
temp_pic=Image.new("RGB",douyin.size,(0,0,0))
temp_pic.paste(douyin_gb,(10,10))
array_gb_new=np.array(temp_pic)
res_array=array_r+array_gb_new
douyin_res=Image.fromarray(res_array)
axes[0][0].imshow(array_r)
axes[0][1].imshow(array_g)
axes[0][2].imshow(array_b)
axes[1][0].imshow(douyin)
axes[1][1].imshow(douyin_res)
plt.show()
同理其它图片也是一样。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有