案例© Fu Xianjun. All Rights Reserved.
一:导入图片
import cv2 #导包
tp=cv2.imread("shape.jpg") #导图
二:利用for循环对像素进行处理
h,w,c=tp.shape #获取长、宽、通道数
for i in range(h): #进入循环
for j in range(w):
for k in range(c):
if tp[i,j,0]<180 and tp[i,j,0]>150: #判断蓝色区域
tp[i,j]=0 #变为黑色
三:显示处理结果
cv2.imshow('shape',tp)
cv2.waitKey()
cv2.destroyAllWindows()
原图
效果图