cutoff = np.array([5, 20, 45, 60]) order = np.array([1, 2, 3, 4]) for i in cutoff: for j in order: p6mask = noise.butterworthLowpassFilter(brain_size, i, j) p6applied = util.applyMask(dft_brain, p6mask) p6image = util.getImage(p6applied) p6fimage = util.post_process_image(p6image) filename = "p6_Masked_Image_" + str(i) + "_" + str(j) + ".jpg" snr_p6 = util.signalToNoise(brain, p6fimage) print(filename, snr_p6) util.saveImage(filename, p6fimage) glhp = np.array([200, 40, 120, 10]) for k in glhp: p7lmask = noise.gaussianLowpassFilter(brain_size, k) p7lapplied = util.applyMask(dft_brain, p7lmask) p7limage = util.getImage(p7lapplied) p7lfimage = util.post_process_image(p7limage) filename = "p7_GLP_Masked_Image_" + str(k) + ".jpg" util.saveImage(filename, p7lfimage) p7hmask = noise.gaussianHighpassFilter(brain_size, k) 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)
# Use this file as you wish to generate the images needed to answer the report import src.project.Utilities as util import src.project.ImageSynthesisNoise as isn import cv2 import numpy as np # image = util.loadImage('images/brain.png') matrix = util.loadMatrix('images/noisyimage.npy') rows, cols = matrix.shape mask = isn.gaussianLowpassFilter((rows, cols), cutoff=40) im = np.multiply(matrix, mask) im = util.post_process_images(util.getImage(im)) # im = np.abs(matrix) # im = util.post_process_images(im) # rows, cols = image.shape util.displayImage(im) # mask = isn.butterworthLowpassFilter((rows, cols), cutoff=40, order=7) # mask = isn.gaussianHighpassFilter((rows, cols), cutoff=150) # shift_fft = util.getDFT(image) # filtered_image_fft = np.multiply(mask, shift_fft) # filtered_image = util.post_process_images(util.getImage(filtered_image_fft)) # util.saveImage('butterworthLowpassFilter.png', filtered_image) # print(util.signalToNoise(filtered_image)) # util.displayImage(filtered_image)
def test_gaussianLowpassFilter_half_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.gaussianLowpassFilter(self.emptymask, 100) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual))