# 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 heart = "images/cardiac.jpg" brain = "images/brain.png" matrix = "images/noisyimage.npy" ############## Utilities ################### img = util.loadImage(heart) img2 = util.loadImage(brain) img3 = util.loadMatrix(matrix) # util.displayImage(img) # util.displayImage(img2) #util.displayImage(img) h = img.shape[0] w = img.shape[1] h1 = img2.shape[0] w1 = img2.shape[1] w2 = img3.shape[1] h2 = img3.shape[0] print(h2) print(w2) mask_size = (h, w) mask_size2 = (h1, w1) #img_copy = util.getDFT(img2)
# 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)
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) 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)