Logo elodees  elodees

A caring AI for a better world













Only alphabetic characters accented or not as well as the space are accepted

Logo IA




Edge detection





No account yet ?

Sign up to access all content


Tested in Anaconda and Python 3.7

import cv2
from matplotlib import pyplot as plt
 
def showimage(myimage, figsize=[10,10]):
    if (myimage.ndim>2):  #This only applies to RGB or RGBA images (e.g. not to Black and White images)
        myimage = myimage[:,:,::-1] #OpenCV follows BGR order, while matplotlib likely follows RGB order
 
    fig, ax = plt.subplots(figsize=figsize)
    ax.imshow(myimage, cmap = 'gray', interpolation = 'bicubic')
    plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
    plt.show()
 
image=cv2.imread('carre-03.jpg')
showimage(image)
 
gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
 
edged=cv2.Canny(gray,30,200)
showimage(edged)
 
_, contours, hierarchy=cv2.findContours(edged,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
 
# print(contours)
# print('Numbers of contours found=' + str(len(contours)))
 
#use -1 as the 3rd parameter to draw all the contours
cv2.drawContours(image,contours,-1,(0,255,0),3)
showimage(image)
 


Original image

Free image provided by pexel.com

Canny

Free image provided by pexel.com

Edges

Free image provided by pexel.com

Original image

Free image provided by pexel.com

Canny

Free image provided by pexel.com

Edges

Free image provided by pexel.com

Original image

Free image provided by pexel.com

Canny

Free image provided by pexel.com

Edges

Free image provided by pexel.com












Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !

Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License