import matplotlib.pyplot as plt import cv2 from fungsi import noisy from fungsi import ftAritmatik from fungsi import ftMedian from fungsi import ftAlphaTrimmedMean from fungsi import countQuality # Open Image -> Grayscale imgAsli = cv2.imread('img/d.png', cv2.IMREAD_GRAYSCALE) # Add Noisy imgNoisy = noisy("s&p", imgAsli) # 1. Show image cv2.imshow('Gambar Noisy', imgNoisy) print("Mean Squared Error (Noisy) : ", countQuality(imgAsli, imgNoisy)) # 2. Show histogram histr = cv2.calcHist([imgNoisy], [0], None, [256], [0, 256]) plt.plot(histr) plt.title("Gambar Noisy") plt.ylabel("frequency") plt.xlabel("range") plt.show() # A. Filter Rata rata Aritmatik # 1. Show image A = ftAritmatik(imgNoisy) cv2.imshow('Filter Rata rata Aritmatik', A) print("Mean Squared Error (Filter Rata rata Aritmetik) : ", countQuality(imgAsli, A))
from fungsi import ftAritmatik from fungsi import ftMedian from fungsi import ftAlphaTrimmedMean from fungsi import countQuality # Open Image -> Grayscale imgAsli = cv2.imread('img/c.png', cv2.IMREAD_GRAYSCALE) # Add Noisy imgNoisy=noisy("s&p",imgAsli) # 1. Show image cv2.imshow('Gambar Noisy',imgNoisy) print("Mean Squared Error (Noisy) : ",countQuality(imgAsli,imgNoisy)) # 2. Show histogram histr = cv2.calcHist([imgNoisy],[0],None,[256],[0,256]) plt.plot(histr) plt.title("Gambar Noisy") plt.ylabel("frequency") plt.xlabel("range") plt.show() # A. Filter Rata rata Aritmatik # 1. Show image A=ftAritmatik(imgNoisy) cv2.imshow('Filter Rata rata Aritmatik',A)