Skip to content

Instantly share code, notes, and snippets.

@yokeshrana
Last active March 28, 2021 16:04
Show Gist options
  • Save yokeshrana/9a59603c5f76d68cad3a87e7e8ca211b to your computer and use it in GitHub Desktop.
Save yokeshrana/9a59603c5f76d68cad3a87e7e8ca211b to your computer and use it in GitHub Desktop.
Experimenting with Blur ,Dialte and Gray scale Images
import cv2
import numpy as np
img = cv2.imread("Resources/lena.png")
imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # converting to it gray scale image
cv2.imshow("GrayScale", imgGray)
# To Blur the image we will use Gaussian Blur to blur
imgBlur = cv2.GaussianBlur(imgGray,(7,7),0) # as a paramter kernel size is passed
cv2.imshow("GrayScaleBlur", imgBlur)
# To detect the edges we use the Canny Filter
imgCanny = cv2.Canny(imgGray,150,100)
cv2.imshow("Canny_Edge",imgCanny)
# Dialate the images
# inedge detection we didnt get the thick lines so what we can do is to increase thickness is dialate the image
kernel = np.ones((5,5), np.uint8)
imgDialted = cv2.dilate(imgCanny,kernel ,iterations=1)
cv2.imshow("Dialted Image ", imgDialted)
# Erode the image
imgEroded=cv2.erode(imgCanny,kernel,iterations=1)
cv2.imshow("Eroded Image ", imgCanny)
cv2.waitKey(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment