Assignment 3: Blurring, Edge, Sharpening

 Image Link: https://drive.google.com/drive/folders/1I_W9sVXhkm1Ofipu2-GelMfyrp3jViu-?usp=share_link


Blurring, Edge, Sharpening

Code:

import numpy as np
import matplotlib.pyplot as plt
import cv2
from scipy import signal

im = plt.imread(r'bird.png')[:,:,:3]

imGray = cv2.cvtColor(im,cv2.COLOR_RGB2GRAY)

smoothingMask = np.ones((15,15))/225

imBlurred = signal.convolve2d(imGray,smoothingMask, boundary='symm',mode='same')

fig,(ax1,ax2) = plt.subplots(1,2,figsize=(10,15))
ax1.imshow(imGray,cmap='gray')
ax2.imshow(imBlurred,cmap='gray')

# Edge:


xMask = np.array([[-1,0,1],[-1,0,1],[-1,0,1]])
yMask = xMask.T.copy()

fx = signal.convolve2d(imGray,xMask,boundary='symm',mode='same')
fy = signal.convolve2d(imGray,yMask,boundary='symm',mode='same')

fx.shape

imGray.shape

Gm = (fx**2 + fy**2)**0.5

plt.imshow(Gm,cmap = 'gray')

th = Gm.max()-4*Gm.std()

E = Gm>th
plt.imshow(Gm>0.1,cmap = 'gray')

# Sharping


imSharped = imBlurred + 0.5*Gm

fig,(ax1,ax2) = plt.subplots(1,2,figsize=(10,15))
ax1.imshow(imBlurred,cmap='gray')
ax2.imshow(imSharped,cmap = 'gray')

Comments

Popular posts from this blog

Assignment 4: Canny Edge Detection

Assignment 1.2 - Transformation

Assignment 1.1: Image Transformation in Python