p7happlied = util.applyMask(dft_brain, p7hmask) p7himage = util.getImage(p7happlied) p7hfimage = util.post_process_image(p7himage) filename = "p7_GHP_Masked_Image_" + str(k) + ".jpg" util.saveImage(filename, p7hfimage) noisy = util.loadMatrix("images/noisyimage.npy") noisy_2 = noisy.real.astype(np.complex128) noisy_image = util.getImage(noisy_2) noisyfi = util.post_process_image(noisy_image) #util.displayImage(noisyfi) noisy_2_write = util.writableDFT(noisy_2) #util.displayImage_plt(noisy_2_write) height_noisy, width_noisy = noisy_2.shape noisy_size = np.array([height_noisy, width_noisy]) p8mask1 = noise.butterworthLowpassFilter(noisy_size, 99, 100) p8mask2 = noise.gaussianLowpassFilter(noisy_size, 50) p8mask3 = noise.idealLowpassFilter(noisy_size, 99) p8applied1 = util.applyMask(noisy_2, p8mask1) p8applied2 = util.applyMask(noisy_2, p8mask2) p8applied3 = util.applyMask(noisy_2, p8mask3) p8image1 = util.getImage(p8applied1) p8image2 = util.getImage(p8applied2) p8image3 = util.getImage(p8applied3) p8fimage1 = util.post_process_image(p8image1) p8fimage2 = util.post_process_image(p8image2) p8fimage3 = util.post_process_image(p8image3) util.saveImage("p8_Buttersworth_99_100.jpg", p8fimage1) util.saveImage("p8_Gaussian_50.jpg", p8fimage1) util.saveImage("p8_Ideal_99.jpg", p8fimage1)
# count = 0 # for cut in cutout: # print(cut) # mask = isn.gaussianHighpassFilter(mask_size2, cut) # a = util.applyMask(img_copy, mask) # b = util.writableDFT(a) # c = util.normalizeImage(b) # d = util.post_process_image(c) # count += 1 # print(count) # util.displayImage(d) nmask_size = (h2, w2) img_copy = util.getImage(img3) mask = isn.idealHighpassFilter(nmask_size, 100) mask1 = isn.idealLowpassFilter(nmask_size, 100) mask2 = isn.gaussianHighpassFilter(nmask_size, 100) mask3 = isn.ringLowpassFilter(nmask_size, 100, 10) mask4 = isn.butterworthHighpassFilter(nmask_size, 50, 2) masks = (mask, mask1, mask2, mask3, mask4) count = 0 for mask in masks: a = util.applyMask(mask, img_copy) count += 1 print(count) util.displayImage(a)
def test_idealLowpassFilter_half_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.idealLowpassFilter(self.emptymask, 100) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual))