Data-Science-Regular-Bootcamp
Data-Science-Regular-Bootcamp copied to clipboard
Color blocks detection and label in OpenCV
import cv2
import numpy as np
img = cv2.imread("test.png", 0)
img = cv2.GaussianBlur(img,(3,3),0)
canny = cv2.Canny(img, 50, 150)
cv2.imshow('Canny', canny)
cv2.waitKey(0)
cv2.destroyAllWindows()
run this code it will work in collab
import matplotlib.pyplot as plt import matplotlib.patches as patches from PIL import Image import numpy as np from google.colab.patches import cv2_imshow import cv2
img = cv2.imread("geek.png") # Read image
Defining all the parameters
t_lower = 100 # Lower Threshold t_upper = 200 # Upper threshold aperture_size = 5 # Aperture size L2Gradient = True # Boolean
Applying the Canny Edge filter
with Aperture Size and L2Gradient
edge = cv2.Canny(img, t_lower, t_upper, apertureSize = aperture_size, L2gradient = L2Gradient )
cv2_imshow(img) cv2_imshow(edge) cv2.waitKey(0) cv2.destroyAllWindows()