|
|
@@ -34,6 +34,11 @@ else: |
|
|
|
|
|
|
|
image = img.copy() |
|
|
|
|
|
|
|
# 图片锐化 |
|
|
|
kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]], np.float32) |
|
|
|
img = cv2.filter2D(img, -1, kernel=kernel) |
|
|
|
cv2.imshow('sharpening', img) |
|
|
|
|
|
|
|
# 边缘保护滤波 |
|
|
|
img = cv2.edgePreservingFilter(img) |
|
|
|
cv2.imshow('edgePreservingFilter', img) |
|
|
@@ -129,7 +134,7 @@ cv2.imshow('houghLinesImage', houghLinesImage) |
|
|
|
|
|
|
|
# Hough变换 |
|
|
|
thresh_min = min(dst.shape) |
|
|
|
lines = cv2.HoughLinesP(dst, 1, np.pi / 180, 200, minLineLength=int(dst.shape[0] * 0.47), maxLineGap=int(thresh_min * 0.5)) |
|
|
|
lines = cv2.HoughLinesP(dst, 1, np.pi / 180, 200, minLineLength=int(dst.shape[0] * 0.45), maxLineGap=int(thresh_min * 0.5)) |
|
|
|
|
|
|
|
houghLinesImage = img.copy() |
|
|
|
for line in lines: |
|
|
@@ -139,8 +144,8 @@ cv2.imshow('houghLinesImage', houghLinesImage) |
|
|
|
|
|
|
|
|
|
|
|
if lines is not None: |
|
|
|
lines_vertical = filter(lambda line: True if abs(line[0][1] - line[0][3]) > length * 0.5 else False, lines) |
|
|
|
lines_horizontal = filter(lambda line: True if abs(line[0][0] - line[0][2]) > height * 0.5 else False, lines) |
|
|
|
lines_vertical = filter(lambda line: True if abs(line[0][1] - line[0][3]) > length * 0.2 else False, lines) |
|
|
|
lines_horizontal = filter(lambda line: True if abs(line[0][0] - line[0][2]) > height * 0.2 else False, lines) |
|
|
|
|
|
|
|
# lines_vertical = filter(isVerticalLine, lines_vertical) |
|
|
|
# lines_horizontal = filter(isHorizontalLine, lines_horizontal) |
|
|
|