(image, threshold_low=15, threshold_high=30, weak=128, strong=255)
| 117 | |
| 118 | |
| 119 | def canny(image, threshold_low=15, threshold_high=30, weak=128, strong=255): |
| 120 | # gaussian_filter |
| 121 | gaussian_out = img_convolve(image, gen_gaussian_kernel(9, sigma=1.4)) |
| 122 | # get the gradient and degree by sobel_filter |
| 123 | sobel_grad, sobel_theta = sobel_filter(gaussian_out) |
| 124 | gradient_direction = PI + np.rad2deg(sobel_theta) |
| 125 | |
| 126 | destination = suppress_non_maximum(image.shape, gradient_direction, sobel_grad) |
| 127 | |
| 128 | detect_high_low_threshold( |
| 129 | image.shape, destination, threshold_low, threshold_high, weak, strong |
| 130 | ) |
| 131 | |
| 132 | track_edge(image.shape, destination, weak, strong) |
| 133 | |
| 134 | return destination |
| 135 | |
| 136 | |
| 137 | if __name__ == "__main__": |
no test coverage detected