Last active
October 11, 2019 13:48
-
-
Save FienSoP/b2612c4b8aa519fc4559749c1c2c7f02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hysteresis(img, weak, strong=255): | |
M, N = img.shape | |
for i in range(1, M-1): | |
for j in range(1, N-1): | |
if (img[i,j] == weak): | |
try: | |
if ((img[i+1, j-1] == strong) or (img[i+1, j] == strong) or (img[i+1, j+1] == strong) | |
or (img[i, j-1] == strong) or (img[i, j+1] == strong) | |
or (img[i-1, j-1] == strong) or (img[i-1, j] == strong) or (img[i-1, j+1] == strong)): | |
img[i, j] = strong | |
else: | |
img[i, j] = 0 | |
except IndexError as e: | |
pass | |
return img |
i think here is mistake, for each neigbours you must do this checking recursively
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In canny algorithm: "This can be done by starting at the known edge pixels and moving in all eight directions recursively until the gradient magnitude is less than or equal to the low threshold". I don't see recursive here. Can you explain your code when you determine eight directions of current pixel without considering from "sure-edge" pixel ?