Skip to content

Instantly share code, notes, and snippets.

@lucifermorningstar1305
Created January 4, 2020 14:38
Show Gist options
  • Save lucifermorningstar1305/7ab3d3d8e24ba1a4dbe4bee30fe57094 to your computer and use it in GitHub Desktop.
Save lucifermorningstar1305/7ab3d3d8e24ba1a4dbe4bee30fe57094 to your computer and use it in GitHub Desktop.
Sobel Edge Filter Algorithm
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
Hx = np.array([[1,0,-1], [2,0,-2],[1,0,-1]], dtype=np.float32)
Hy = np.array([[-1,-2,-1],[0,0,0],[1,2,1]], dtype=np.float32)
Gx = scipy.signal.convolve2d(Gm, Hx, mode ='same')
Gy = scipy.signal.convolve2d(Gm,Hy,mode = 'same')
G = (Gx*Gx + Gy*Gy) ** 0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment