#==============遍历图像改变颜色================================
height, width, channels = img.shape
new_im = np.ones((height, width, 4)) * 255
new_im[:, :, :3] = img
# print('img的rol是{},col是{}'.format(r,c))
for i in range(0,new_im.shape[0]):
for j in range(0,new_im.shape[1]):
if new_im[i, j][0] != 255:
new_im[i,j] = (0, 0, 0, 0)
#=========================================================
#=====================三维==============================
height, width, channels = result1.shape
new_im = np.ones((height, width, 3)) * 255
new_im[:, :, :3] = result1
# print('img的rol是{},col是{}'.format(r,c))
for i in range(0,new_im.shape[0]):
for j in range(0,new_im.shape[1]):
if new_im[i, j][0] != 255:
new_im[i,j] = (0, 0, 0)
#======================================================
python--opencv 图像遍历改变像素颜色(三维与四维透明)
最新推荐文章于 2024-02-06 11:58:40 发布