作者:ccccting
案列:© Fu Xianjun. All Rights Reserved.
目录
图像颜色
导库
import cv2
import numpy as np
代码
img = cv2.imread("1.jpg")
print (img.shape)
gao, chang , tongdaoshu = img. shape
print("gao:%s, chang:%s, tongdao:%s"%(gao,chang, tongdaoshu))
b,g,r = cv2.split(img)
zeros = np.zeros ((500,500,3) ,dtype="uint8")
for i in range (0,chang)
for j in range(0,chang):
for k in range(0,3)
if 159< b[i,j]<200:
img[i,j] = (0,0,0,)
cv2.imshow("2" , img)
cv2.imwrite ("2.jpg" , img)
cv2.waitKey(0)
Cv2.destroyAllWindows()
本文介绍了一种使用Python的OpenCV库进行图像颜色处理的方法。通过读取图像文件并将其拆分为不同的颜色通道,然后对蓝色通道进行特定阈值处理来修改图像中的颜色。该文展示了如何创建全零矩阵,并对符合条件的像素点进行颜色替换。
10万+

被折叠的 条评论
为什么被折叠?



