Esempio n. 1
0
        def update(val):
            H = myFunc.getBWlp(P, Q, int(sn.val), int(sD0.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")
Esempio n. 2
0
 def onVwSpec(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)
     # padding before taking Fourier Transoffrm
     #temp, _, _ = pad2(self.I2)
     #temp = self.I2
     temp = np.float64(self.I2)
     F,_,_ = myFFT.fft2(temp)
     F = myFFT.fftshift(F)
     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(orientation='horizontal')
     cbar.set_label('Frequency Amplitudes')
     plt.show()
Esempio n. 3
0
        def update(val):
            H = 1.0 - myFunc.getBWlp(P, Q, int(sn.val), int(sD0.val))
            temp = myFFT.ifft2(myFFT.fftshift(np.multiply(F , H)),p,q)
            temp = self.I2 + temp#unpad2(temp, P, Q)
            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")
Esempio n. 4
0
    def onBwLp(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)
        n = 10
        D0 = np.min([P,Q])/4
        H = myFunc.getBWlp(P, Q, n, D0)
        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'
        axD0 = fig.add_axes([0.1, 0.025, 0.3, 0.025], axisbg=axcolor)
        axn  = fig.add_axes([0.6, 0.025, 0.3, 0.025], axisbg=axcolor)

        sD0 = Slider(axD0, 'Cut Off freq.', 20, np.min([P / 40 * 20, Q / 40 * 20]), valinit=D0)
        sn = Slider(axn, "degree 'n'", 1, 25, valinit=n)

        def update(val):
            H = myFunc.getBWlp(P, Q, int(sn.val), int(sD0.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")

        sD0.on_changed(update)
        sn.on_changed(update)
        fig.show()
Esempio n. 5
0
    def onGaussianHp(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]) / 5
        H = 1.0 - myFunc.getGaussianlp(P, Q, sigma)
        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)

        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 / 50 * 20, Q / 50 * 20]), valinit=sigma)

        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")

        sSigma.on_changed(update)
        fig.show()