【问题标题】:Detect if image is pixelated using canny and hough transform使用 canny 和 hough 变换检测图像是否像素化
【发布时间】:2018-12-09 02:32:36
【问题描述】:

我在网上阅读,发现可以根据使用边缘检测器检测到的行数然后应用霍夫变换来判断图像是否像素化。
我尝试了该方法,但霍夫变换似乎无法正确检测线条我无法弄清楚为什么它不能正常工作。
以下是一些结果图片供参考:canny边缘检测结果

和霍夫变换结果


我可以做些什么来改善线路检测?
我根据一些在线教程使用的代码:

img = cv2.imread(image_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

high_thresh, thresh_im = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
lowThresh = 0.5*high_thresh
edges = cv2.Canny(img, lowThresh, high_thresh)

minLineLength = 200
maxLineGap = 10
lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)
for x1,y1,x2,y2 in lines[0]:
    cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)

cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

【问题讨论】:

  • 检测具有完全恒定颜色的正方形而不是寻找边缘会非常有效。

标签: opencv edge-detection hough-transform canny-operator pixelate


【解决方案1】:
edges = cv2.Canny(gray,50,150,apertureSize = 3)
minLineLength = 200
maxLineGap = 10
lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)
# edited this line
for line in lines:
    x1,y1,x2,y2 = line[0]
    cv2.line(image,(x1,y1),(x2,y2),(0,255,0),2)

【讨论】:

    猜你喜欢
    • 2013-01-03
    • 1970-01-01
    • 1970-01-01
    • 2019-03-19
    • 2020-09-07
    • 2011-09-12
    • 2019-11-22
    • 2015-12-11
    • 2012-10-08
    相关资源
    最近更新 更多