Skip to content

arulalanv/Edge-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Edge-Detection

Canny Edge Detection using OpenCV package

  • Step 1: Write the code in Text Editor #!/usr/bin/python # -- coding: latin-1 -- # import the necessary packages import argparse import cv2 # construct the argument parser and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-i", "--image", required=True, help="Path to the image") args = vars(ap.parse_args()) # load the image, convert it to grayscale, and blur it slightly # While Canny edge detection can be applied to an RGB image by detecting edges in each of # the separate Red, Green, and Blue channels separately and combining the results back. together, we almost always want to apply edge detection to a single channel, grayscale image # this ensures that there will be less noise during the edge detection process. image = cv2.imread(args["image"]) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) blurred = cv2.GaussianBlur(gray, (5, 5), 0) # show the original and blurred images cv2.imshow("Original", image) cv2.imshow("Blurred", blurred) # compute a "wide", "mid-range", and "tight" threshold for the edges. # supply the Tlower and Tupper thresholds, respectively wide = cv2.Canny(blurred, 10, 200) mid = cv2.Canny(blurred, 50, 150) tight = cv2.Canny(blurred, 240, 250) # show the edge maps cv2.imshow("Wide Edge Map", wide) cv2.imshow("Mid Edge Map", mid) cv2.imshow("Tight Edge Map", tight) cv2.waitKey(0)
  • Step 2: Save the code as "edgeDetection.py"
  • Step 3: Run the python script (edgeDetection.py) from command window Go to root folder $ python edgeDetection.py -i apj.jpg or $ python edgeDetection.py --image apj.jpg

About

Canny Edge Detection using OpenCV

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages