Coder Social home page Coder Social logo

canny-edge-detection's Introduction

Canny-Edge-Detection

To implement the Canny edge detection algorithm on an image

PYTHON PROGRAM

Register Number : 212221243002
Developed by    : Sanjay S
import cv2
import matplotlib.pyplot as plt
san = 'san.jpg'
san2 = cv2.imread(san, cv2.IMREAD_GRAYSCALE)
if san2 is None:
    print("Error: Could not load image")
    exit()
edges = cv2.Canny(san2, threshold1=100, threshold2=200)
plt.figure(figsize=(10, 5))

alt text

plt.subplot(1, 2, 1)
plt.title('Original Image')
plt.imshow(san2, cmap='gray')
plt.axis('off')

alt text

plt.subplot(1, 2, 2)
plt.title('Edges')
plt.imshow(edges, cmap='gray')
plt.axis('off')

alt text

plt.tight_layout()
plt.show()

alt text

parameters = [
    (50, 150),  
    (100, 200),
    (150, 250)
]
san2 = cv2.imread(san, cv2.IMREAD_GRAYSCALE)
plt.figure(figsize=(15, 5))

alt text

for i, (threshold1, threshold2) in enumerate(parameters):
    edges = cv2.Canny(san2, threshold1, threshold2)
    plt.subplot(1, 3, i + 1)
    plt.title(f'Thresholds: {threshold1}, {threshold2}')
    plt.imshow(edges, cmap='gray')
    plt.axis('off')

alt text

plt.tight_layout()
plt.show()   

alt text

canny-edge-detection's People

Contributors

sanjay5656 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.