SHARE
TWEET

Untitled

a guest Mar 21st, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import cv2
  2. import numpy as np
  3.  
  4. image = cv2.imread('images/input.jpg',0)
  5.  
  6. height, width = image.shape
  7.  
  8. # Extract Sobel Edges
  9. sobel_x = cv2.Sobel(image, cv2.CV_64F, 0, 1, ksize=5)
  10. sobel_y = cv2.Sobel(image, cv2.CV_64F, 1, 0, ksize=5)
  11.  
  12. cv2.imshow('Original', image)
  13. cv2.waitKey(0)
  14. cv2.imshow('Sobel X', sobel_x)
  15. cv2.waitKey(0)
  16. cv2.imshow('Sobel Y', sobel_y)
  17. cv2.waitKey(0)
  18.  
  19. sobel_OR = cv2.bitwise_or(sobel_x, sobel_y)
  20. cv2.imshow('sobel_OR', sobel_OR)
  21. cv2.waitKey(0)
  22.  
  23. laplacian = cv2.Laplacian(image, cv2.CV_64F)
  24. cv2.imshow('Laplacian', laplacian)
  25. cv2.waitKey(0)
  26.  
  27.  
  28.  
  29.  
  30.  
  31. ##  Then, we need to provide two values: threshold1 and threshold2. Any gradient value larger than threshold2
  32. # is considered to be an edge. Any value below threshold1 is considered not to be an edge.
  33. #Values in between threshold1 and threshold2 are either classified as edges or non-edges based on how their
  34. #intensities are “connected”. In this case, any gradient values below 60 are considered non-edges
  35. #whereas any values above 120 are considered edges.
  36.  
  37.  
  38. # Canny Edge Detection uses gradient values as thresholds
  39. # The first threshold gradient
  40. canny = cv2.Canny(image, 50, 120)
  41. cv2.imshow('Canny', canny)
  42. cv2.waitKey(0)
  43.  
  44. cv2.destroyAllWindows()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top