from PIL import Image
import os
import numpy as np
import time
def replace_color(img, src_clr, dst_clr):
'''
通过矩阵操作颜色替换程序
:param img: 图像矩阵
:param src_clr: 需要替换的颜色(r,g,b)
:param dst_clr: 目标颜色(r,g,b)
:return: 替换后的图像矩阵
'''
img_arr = np.asarray(img, dtype=np.double)
#分离通道
r_img = img_arr[:,:,0].copy()
g_img = img_arr[:,:,1].copy()
b_img = img_arr[:,:,2].copy(
[Python]更改图片底色
最新推荐文章于 2024-09-22 17:18:11 发布