# 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)
Beispiel #2
0
# 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)
Beispiel #3
0
# Use this file as you wish to generate the images needed to answer the report

import src.project.Utilities as util
import numpy as np
import src.project.SelectiveImageAcquisition as sia

image = util.loadImage('images/brain.png')
rows, cols = image.shape
print(image.shape)
# code for cardiac cartesian
# mask = sia.cartesianPattern((rows, cols), 0.7)
mask = sia.circlePattern((rows, cols), 90)

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.displayImage(filtered_image)

mask1 = sia.cartesianPattern(mask_size2, .05)
mask2 = sia.cartesianPattern(mask_size2, .15)
mask3 = sia.cartesianPattern(mask_size2, .35)
mask4 = sia.cartesianPattern(mask_size2, .64)

masks = (mask1, mask2, mask3, mask4)

count = 0
for mask in masks:
    a = util.applyMask(img_copy2, mask)
    b = util.writableDFT(a)
    c = util.normalizeImage(b)
    d = util.post_process_image(c)
    count += 1
    print(count)
    util.displayImage(d)

##############  Part 4  #####################

#change img(heart) to img2(brain)
# img_copy = util.getDFT(img2)
# rays = (1, 15, 50, 100, 360)
#
# mask = sia.radialPattern(mask_size2, rays[0])
#
# mask1 = sia.radialPattern(mask_size2, rays[1])
# mask2 = sia.radialPattern(mask_size2, rays[2])
# mask3 = sia.radialPattern(mask_size2, rays[3])
# mask4 = sia.radialPattern(mask_size2, rays[4])
#
# masks = (mask1, mask2, mask3, mask4)