def update(val): H = myFunc.getGaussianlp(P, Q, int(sSigma.val)) temp = myFFT.ifft2(myFFT.fftshift(np.multiply(F , H)),p,q) #temp = unpad2(temp, P, Q) temp = np.uint8(np.abs(temp)) self.onPanel2(temp) fig.add_subplot(223) plt.imshow(temp, cmap = plt.cm.gray) plt.yticks([]) plt.xticks([]) plt.title("Filtered Image") fig.add_subplot(224) plt.imshow(H, cmap = plt.cm.gist_heat) plt.yticks([]) plt.xticks([]) plt.title("Frequency Response")
def update(val): H = 1.0 - myFunc.getGaussianlp(P, Q, int(sSigma.val)) temp = myFFT.ifft2(myFFT.fftshift(np.multiply(F , H)), p, q) temp = self.I2 + temp np.putmask(temp, temp > 255, 255) # check overflow np.putmask(temp, temp < 0, 0) # check underflow temp = np.uint8(np.abs(temp)) self.onPanel2(temp) fig.add_subplot(223) plt.imshow(temp, cmap = plt.cm.gray) plt.yticks([]) plt.xticks([]) plt.title("Filtered Image") fig.add_subplot(224) plt.imshow(H, cmap = plt.cm.gist_heat) plt.yticks([]) plt.xticks([]) plt.title("Frequency Response")
def onGaussianLp(self): self.I2 = self.Ilast if self.Ilast.ndim == 3 : tkMessageBox.showinfo("Message", "Image will be converted to Grayscale.") self.I2 = myThresh.gray(self.I2) #tempI, P, Q = pad2(self.I2) tempI = np.float64(self.I2) F,p,q = myFFT.fft2(tempI) P, Q = F.shape F = myFFT.fftshift(F) sigma = np.min([P,Q])/10 H = myFunc.getGaussianlp(P, Q, sigma) temp = myFFT.ifft2(myFFT.fftshift(np.multiply(F , H)),p,q) #temp = unpad2(temp, P, Q) temp = np.uint8(np.abs(temp)) self.onPanel2(temp) plt.clf() fig = plt.figure(figsize=(16,9),facecolor='w') fig.add_subplot(221) plt.subplots_adjust(left = 0, bottom=0.06, right = 1, top = 0.95, hspace = 0.1, wspace = 0) plt.imshow(self.I2, cmap = plt.cm.gray) plt.yticks([]) plt.xticks([]) plt.title("Original Image") fig.add_subplot(222) pwrSpec = np.log10(1 + np.abs(F) ** 2) plt.imshow(pwrSpec, cmap = plt.cm.PRGn) plt.yticks([]) plt.xticks([]) plt.title("Power Spectrum") cbar = plt.colorbar(ticks = []) cbar.set_label(r'Spectral Power') fig.add_subplot(223) plt.imshow(temp, cmap = plt.cm.gray) plt.yticks([]) plt.xticks([]) plt.title("Filtered Image") fig.add_subplot(224) plt.imshow(H, cmap = plt.cm.gist_heat) plt.yticks([]) plt.xticks([]) plt.title("Frequency Response") cbar = plt.colorbar(ticks = []) cbar.set_label(r'Amplitude') axcolor = 'lightgoldenrodyellow' axSigma = fig.add_axes([0.2, 0.025, 0.5, 0.025], axisbg=axcolor) sSigma = Slider(axSigma, 'Cut Off freq.( Sigma)', 5, np.min([P / 100 * 20, Q / 100 * 20]), valinit=sigma) def update(val): H = myFunc.getGaussianlp(P, Q, int(sSigma.val)) temp = myFFT.ifft2(myFFT.fftshift(np.multiply(F , H)),p,q) #temp = unpad2(temp, P, Q) temp = np.uint8(np.abs(temp)) self.onPanel2(temp) fig.add_subplot(223) plt.imshow(temp, cmap = plt.cm.gray) plt.yticks([]) plt.xticks([]) plt.title("Filtered Image") fig.add_subplot(224) plt.imshow(H, cmap = plt.cm.gist_heat) plt.yticks([]) plt.xticks([]) plt.title("Frequency Response") sSigma.on_changed(update) fig.show()