SoFunction
Updated on 2024-11-16

Python Method Parameters and Usage

Function Prototypes and Arguments Explained

OpenCV provides the () method, which converts the input raw image to an edge image.

The method is prototyped as:

(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]]) -> 	edges
(dx, dy, threshold1, threshold2[, edges[, L2gradient]]) -> edges
  • The image parameter is the input image in array format.
  • threshold1 and threshold2 are our lower and upper thresholds, respectively.
  • apertureSize is the size of the Sobel kernel used to find the gradient of the image, default is 3.
  • L2gradient specifies the formula for finding the gradient magnitude and is a boolean variable that defaults to False. when it is True, L2 is used, otherwise L1 is used.

Here is the exact code:

def canny_detect(image_path, show=True):
    # Read the image
    image = (image_path, 0)
    # Get results
    edges = (image, 100, 200)
    if show:
        # Drawing the original
        (121)
        (image, cmap='gray')
        ('Original Image')
        ([])
        ([])

        # Mapping the edges
        (122)
        (edges, cmap='gray')
        ('Edge Image')
        ([])
        ([])
        ()
    return edges
canny_detect('images/')

effect

to this article on the Python () method parameters and methods of use of the article is introduced to this, more related Python () method content, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future more!