Skip to content

Instantly share code, notes, and snippets.

View Achyut-Krishna's full-sized avatar
💭
I may be slow to respond.

Achyut Krishna Sai Adiraju Achyut-Krishna

💭
I may be slow to respond.
View GitHub Profile
@Achyut-Krishna
Achyut-Krishna / Read.py
Last active April 5, 2022 20:18
Read Display and Write an image to a file (using cv)
import cv2 as cv
import sys
img = cv.imread(cv.samples.findFile("cats.jpg"))
if img is None:
sys.exit("Could not read the image.")
cv.imshow("Display window", img)
k = cv.waitKey(0)
if k == ord("s"):
cv.imwrite("starry_night.png", img)
import cv2 as cv
import sys
img = cv.imread(cv.samples.findFile("cats.jpg"))
@Achyut-Krishna
Achyut-Krishna / check.py
Created April 5, 2022 18:54
check if the image was loaded correctly
if img is None:
sys.exit("Could not read the image.")
cv.imshow("Display window", img)
k = cv.waitKey(0)
if k == ord("s"):
cv.imwrite("cats.png", img)
@Achyut-Krishna
Achyut-Krishna / grayscale.py
Created April 5, 2022 19:16
Converting to grayscale
import cv2 as cv
# Read in an image
img = cv.imread('../Resources/Photos/park.jpg')
cv.imshow('Park', img)
# Converting to grayscale
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow('Gray', gray)
@Achyut-Krishna
Achyut-Krishna / blur.py
Created April 5, 2022 19:25
Program to blur an image
import cv2 as cv
# Read in an image
img = cv.imread('../Resources/Photos/park.jpg')
cv.imshow('Park', img)
#Blur an image
blur = cv.GaussianBlur(img, (7,7), cv.BORDER_DEFAULT)
cv.imshow('Blur', blur)
#library is imported
import cv2 as cv
# Read in an image
img = cv.imread('../Resources/Photos/park.jpg')
cv.imshow('Park', img)
# Edge Cascade
canny = cv.Canny(blur, 125, 175)
cv.imshow('Canny Edges', canny)
# importing opencv CV2 module
import cv2
# bat.jpg is the batman image.
img = cv2.imread('gfg.png')
# make sure that you have saved it in the same folder
# Averaging
# You can change the kernel size as you want
avging = cv2.blur(img,(10,10))