def getDarkMap(img,pitchSize=9):
darkMap=np.zeros(shape=(img.shape[0],img.shape[1]),dtype=np.uint8)
#padding,and darkMap has the same shape with the img
# print ("shape of darkmap",darkMap.shape[0],darkMap.shape[1])
padSize=(pitchSize-1)//2
#print ("type of pitchsize",type(padSize))
pad=cv2.copyMakeBorder(img,padSize,padSize,padSize,padSize,cv2.BORDER_CONSTANT,value=255)
for i in range(darkMap.shape[0]):
for j in range(darkMap.shape[1]):
darkMap[i,j]=pad[i:i+pitchSize,j:j+pitchSize].min()
return pad,darkMap
评论列表
文章目录