0% found this document useful (0 votes)
13 views1 page

Canny Edge Detection in OpenCV

This document summarizes three lines of code used for image processing and computer vision tasks. The first line converts a color image to grayscale. The second line applies Gaussian blur to the original image. The third line detects edges in the grayscale image using the Canny edge detector.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Canny Edge Detection in OpenCV

This document summarizes three lines of code used for image processing and computer vision tasks. The first line converts a color image to grayscale. The second line applies Gaussian blur to the original image. The third line detects edges in the grayscale image using the Canny edge detector.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

gray_image = [Link](image, cv2.

COLOR_BGR2GRAY) # Convert image to grayscale


blurred_image = [Link](image, (5, 5), 0) # Apply Gaussian blur
edges = [Link](gray_image, 100, 200) # Detect edges using Canny edge detector
[Link](image, cv2.COLOR_BGR2GRAY):

This line of code converts the original color image (image) to a grayscale image.
[Link]() is the OpenCV function used to perform color space conversion.
image is the input image that you want to convert.
cv2.COLOR_BGR2GRAY is a flag that specifies the conversion from BGR (blue, green,
red) color space to grayscale. It converts a color image to a single-channel
grayscale image.
[Link](image, (5, 5), 0):

This line applies a Gaussian blur to the original image (image).


[Link]() is the function used for applying a Gaussian blur to an image.
image is the input image on which the blur is applied.
(5, 5) specifies the kernel size (width and height of the Gaussian kernel). Here,
it's a 5x5 kernel.
0 is the standard deviation of the Gaussian kernel in the x-direction. If set to
zero, OpenCV calculates it based on the kernel size.
[Link](gray_image, 100, 200):

This line detects edges in the grayscale image (gray_image) using the Canny edge
detector.
[Link]() is the function used for edge detection using the Canny algorithm.
gray_image is the input grayscale image on which edge detection is performed.
100 and 200 are threshold values used in the Canny algorithm. These values
determine which edges are detected. Any gradient value above the second threshold
(200) is considered an edge, and any value below the first threshold (100) is
considered not an edge. Intermediate values are classified based on their
connectivity to strong edges.
These operations are fundamental in image processing and are often used as
preprocessing steps for various computer vision tasks, such as feature extraction,
object detection, and image analysis.

You might also like