【发布时间】:2020-04-28 20:43:40
【问题描述】:
我想测量鸟瞰图像中的土地面积,因此有人建议我首先使用斑点检测来隔离区域并对图像进行阈值处理。这是我所做的,但我不确定这是否正确。
img = cv2.imread('landarea.jpg', cv2.IMREAD_COLOR)
# Set up the detector with default parameters.
detector = cv2.SimpleBlobDetector_create()
# Detecting blobs.
keypoints = detector.detect(img)
# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size
im_with_keypoints = cv2.drawKeypoints(img, keypoints, np.array([]), (0, 0,
255),cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
# Show keypoints
print(im_with_keypoints.size)
# plt.show()
cv2.imshow("Blob",im_with_keypoints )
cv2.waitKey(0)
cv2.destroyAllWindows()
# Convert to gray
gray = cv2.cvtColor(im_with_keypoints, cv2.COLOR_BGR2GRAY)
#Threshold the image
ret3,th3 = cv2.threshold(gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
titles = ["Otsu's Thresholding"]
images = [th3]
plt.figure(figsize=(15, 10))
for i in range(1):
plt.subplot(1,1,i+1), plt.imshow(images[i], 'gray')
plt.title(titles[i])
plt.xticks([]), plt.yticks([])
plt.show()
总而言之,这就是我想要实现的目标
任务:土地面积测量:
我目前正在从航空测绘图像中获取土地的面积、宽度和高度测量值。下面列出了为实现这一目标而采取的步骤:
有人建议我最好从头开始编写 Python 代码来进行图像处理。
同样来自 SO,我被建议使用斑点检测器来隔离区域、阈值我的图像并计算白色像素的数量。然后我可以用真实尺寸校准图像的尺寸。 我已经能够检测到斑点,对图像进行阈值处理,并且还能够获得白色像素的计数。我的主要挑战是最后两个步骤以及如何从这些步骤中获得测量结果。 还有朋友说,一般照片的形状可以是正方形、长方形等,所以如果我用照片测量面积,面积可能不会变化。
【问题讨论】:
-
发布输入图片的链接。
-
@fmw42 我刚刚添加了图片链接Image Link
-
我认为斑点检测不会很好地工作。您需要以某种方式对图像进行阈值处理,以将陆地区域与其他所有区域分开。您想从图像的哪个部分获取该区域?
-
@fmw42 来自整个图像。
-
@fmw42 我还想将该区域与地面实况区域进行比较,您建议我采取哪些步骤来实现这一目标...?
标签: python opencv image-processing