使用 canny 和 hough 变换检测图像是否像素化

Detect if image is pixelated using canny and hough transform

我在网上阅读,发现可以根据使用边缘检测器检测到的线数然后应用霍夫变换来判断图像是否像素化。
我试过那个方法,霍夫变换似乎没有正确检测到线条我不明白为什么它不能正常工作。
以下是一些结果图片供参考:Canny edge detection result

和霍夫变换结果


如何改进线路检测?
我根据一些在线教程用于执行此操作的代码:

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()
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)