我试着把暗灰色的斑点从角落的模糊灰色区域中分割出来,我做了二进制阈值和形态学操作,它在中间的斑点上效果很好,但是在角落我遇到了一点麻烦。
black and white blob image
# Binary Thresholding
ret,threshImg = cv2.threshold(denoiseImg, 220, 255,cv2.THRESH_BINARY)
threshImg = cv2.bitwise_not(threshImg)
# Morphological Operation
# Initialization of kernel size
kernel2 = np.ones((2,2), np.uint8)
kernel5 = np.ones((5,5), np.uint8)
# Morphological Dilation
dilationImg = cv2.dilate(threshImg, kernel2, iterations = 1) #
# Morphological Closing
closingImg = cv2.morphologyEx(dilationImg, cv2.MORPH_CLOSE, kernel5) # uses closing to fill gaps in the foreground
closingImg = cv2.bitwise_not(closingImg)
这就是结果。segmented blob
1条答案
按热度按时间jq6vz3qz1#
你可以在Python/OpenCV中做除法规范化来缓解这个问题。你基本上是模糊图像,然后用模糊的版本除以图像。
输入:
结果: