Hello guys, I’ve added some Gaussian Noise to my image but it looks like it’s not completely eliminated from my image, what am I doing wrong? This is my code:
# Import numpy, skimage and matplotlib
import numpy as np
from skimage import io,color, util
import matplotlib.pyplot as plt
# Image loading
img = io.imread('tst1.bmp')
# Grayscale conversion
img = color.rgb2gray(img)
# add Gaussian noise to the image
# the variance sets the width of the gaussian
img = util.random_noise(img, mode='gaussian', mean=0, var = (10/255)**2)
img = img*255
# Displaying the grayscale image
plt.figure(),plt.imshow(img,cmap='gray', vmin = 0, vmax = 255), plt.colorbar()
hist,_ = np.histogram(img,range(0,256))
plt.figure(figsize=(10,10)),plt.plot(hist)
segm = np.zeros(img.shape)
segm[img<25] = 0
segm[np.logical_and(img>=25, img<75)] = 1
segm[np.logical_and(img>=75, img<125)] = 2
segm[np.logical_and(img>=125, img<175)] = 3
segm[img>175] = 4
plt.figure(figsize=(10,10)),plt.imshow(segm,cmap='gray', vmin = 0, vmax = 4), plt.colorbar()
And this is my result:
It looks like I still have some salt&pepper noise present, how can I eliminate it? I don’t want to use any Skimage functions built-in Python, I need to use code made by me.