【发布时间】:2018-07-12 07:06:30
【问题描述】:
我正在使用 cv2.findContours 定位卫星照片中的光污染区域。它们中的许多内部并没有完全污染,我的意思是它们内部有黑洞,它们不应该被视为轮廓的一部分,也不是单独的轮廓,因为我只是在描绘光污染区域。当我开始按大小索引轮廓时,我注意到黑洞被视为单独的轮廓。
如您所见,例如 #0、#67 和 #64 被归类为轮廓区域,即使它们不应该是
找到我正在使用的轮廓
# Reading image
image_orig = cv2.imread("india_night.jpg")
# Processing to make contours smoother
image_gray = cv2.cvtColor(image_orig, cv2.COLOR_BGR2GRAY)
image_blurred = cv2.GaussianBlur(image_gray, (5, 5), 0)
image_blurred = cv2.dilate(image_blurred, None)
_, image_threshold = cv2.threshold(image_blurred, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
#sorting contours by size
_, contours, _ = cv2.findContours(image_threshold, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
contours = sorted(contours, key=cv2.contourArea)
我的目标是不将这些未受污染的地区归类为受污染地区
【问题讨论】: