问题描述
我正在尝试检测并从背景中提取图像(示例图像 here)。使用精明的边缘检测和霍夫变换进行线条检测。但是由于图像中的噪声,我得到了错误的结果。示例图像(中间结果)显示为 here。请帮我在python中解决这个问题。
我使用了来自以下站点的技术,并使用了霍夫变换的想法。
https://www.pyimagesearch.com/2014/04/21/building-pokedex-python-finding-game-boy-screen-step-4-6/
解决方法
希望对您有所帮助:
import cv2
img = cv2.imread('image.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)[:,:,2]
kern_size = 11
gray_blurred = cv2.medianBlur(gray,kern_size)
threshold_lower = 30
threshold_upper = 220
edged = cv2.Canny(gray_blurred,threshold_lower,threshold_upper)
cv2.imshow('edged',edged)
cv2.waitKey(0)