In [1]:
import cv2
import os
import matplotlib.pyplot as plt
from ps0 import *
import numpy as np
%matplotlib inline
In [2]:
driver_path = 'input/ps0-1-a-1.jpg'
driver = cv2.imread(driver_path)
show_img(driver)
In [18]:
driver_blur = cv2.GaussianBlur(driver, (7,7), 3, borderType=2)
In [19]:
show_img(driver_blur)
In this section, I'm not totally sure about how to create salt and pepper noise in opencv python. I just used the function below, obtained from previous ps0 solution. If you know any good method of generating salt & pepper noise, please don't hesitate to let me know, thanks a lot!
In [34]:
grid = np.random.normal(0,0.7,driver.shape)
grid = grid.astype('uint8')
driver_salt_pepper = cv2.add(driver, grid)
In [35]:
show_img(driver_salt_pepper)
In [36]:
driver_median_blur = cv2.medianBlur(driver_salt_pepper, 3)
In [37]:
show_img(driver_median_blur)
I think the median filter worked! Hurray!
In [ ]: