Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Koristeći zašumljenu sliku iz prethodnog primera, ukloniti šum upotrebom aritmetičkog usrednjivača veličina:
- 3x3
- 5x5
- 11x11
- Koristeći PSNR odrediti koji filtar je dao objektivno najbolje otklanjanje.
- '''
- import plotly.express as px
- fig = px.imshow(img_noisy, zmin=0, zmax=255, color_continuous_scale='gray')
- fig.show()
- from scipy import ndimage
- import plotly.graph_objects as go
- from plotly.subplots import make_subplots
- # 3x3 aritmeticki usrednjivac
- kernel = np.ones((3,3))/9
- img_f = ndimage.convolve(img_noisy.astype('float'), kernel, mode = 'mirror')
- fig = px.imshow(img_f, zmin=0, zmax=255, color_continuous_scale='gray')
- fig.show()
- psnr = 10*np.log10(255**2/((img - img_f)**2).mean())
- print("PSNR za box filtar dimenzije {} je {}".format(kernel.shape, psnr))
- # 5x5 aritmeticki usrednjivac
- kernel = np.ones((5,5))/25
- img_f = ndimage.convolve(img_noisy.astype('float'), kernel, mode = 'mirror')
- fig = px.imshow(img_f, zmin=0, zmax=255, color_continuous_scale='gray')
- fig.show()
- psnr = 10*np.log10(255**2/((img - img_f)**2).mean())
- print("PSNR za box filtar dimenzije {} je {}".format(kernel.shape, psnr))
- # 11x11 aritmeticki usrednjivac
- kernel = np.ones((11,11))/121
- img_f = ndimage.convolve(img_noisy.astype('float'), kernel, mode = 'mirror')
- fig = px.imshow(img_f, zmin=0, zmax=255, color_continuous_scale='gray')
- fig.show()
- psnr = 10*np.log10(255**2/((img - img_f)**2).mean())
- print("PSNR za box filtar dimenzije {} je {}".format(kernel.shape, psnr))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement