def checkForSkin(IMG10):
high,widt=IMG10.shape[:2]
B1=np.reshape(np.float32(IMG10[:,:,0]),high*widt)#B
G1=np.reshape(np.float32(IMG10[:,:,1]),high*widt)#G
R1=np.reshape(np.float32(IMG10[:,:,2]),high*widt)#Rs
#print high,widt
h3=np.zeros((high,widt,3),np.uint8)
#cv2.imshow("onetime",h)
tem=np.logical_and(np.logical_and(np.logical_and(np.logical_and(R1 > 95, G1 > 40),np.logical_and(B1 > 20, (np.maximum(np.maximum(R1,G1),B1) - np.minimum(np.minimum(R1,G1),B1)) > 15)),R1>B1),np.logical_and(np.absolute(R1-G1) > 15,R1>G1))
h5=np.array(tem).astype(np.uint8,order='C',casting='unsafe')
h5=np.reshape(h5,(high,widt))
h3[:,:,0]=h5
h3[:,:,1]=h5
h3[:,:,2]=h5
#cv2.imshow("thirdtime",h3)
kernel1 = np.ones((3,3),np.uint8)
closedH3=np.copy(h3)
for i in range(5):
closedH3 = cv2.erode(closedH3,kernel1)
for i in range(5):
closedH3 = cv2.dilate(closedH3,kernel1)
#cv2.imshow("closedH3",closedH3)
# closedH3 = cv2.cvtColor(closedH3, cv2.COLOR_BGR2RGB)
return closedH3
评论列表
文章目录