Spaces:
Running
Running
| import cv2 | |
| import numpy as np | |
| def close_small_gaps(binary): | |
| kernel = np.ones((3, 3), np.uint8) | |
| closed = cv2.morphologyEx( | |
| binary, | |
| cv2.MORPH_CLOSE, | |
| kernel, | |
| iterations=1 | |
| ) | |
| return closed | |
| def strengthen_lines(binary): | |
| kernel = np.ones((2, 2), np.uint8) | |
| dilated = cv2.dilate( | |
| binary, | |
| kernel, | |
| iterations=1 | |
| ) | |
| return dilated |