コード例 #1
0
#mask_size2 = (h, w)
percent = .5

mask = sia.cartesianPattern(mask_size2, percent)

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])
コード例 #2
0
import cv2
import numpy as np

import src.project.SelectiveImageAcquisition as aqc
import src.project.Utilities as util

cardiac = util.loadImage("images/cardiac.jpg")
normal_cardiac = util.normalizeImage(cardiac)
dft_cardiac = util.getDFT(normal_cardiac)
write_dft = util.writableDFT(dft_cardiac)
util.saveMatrix("Cardiac_DFT.jpg", write_dft)
height, width = cardiac.shape
cardiac_size = np.array([height, width])

brain = util.loadImage("images/brain.png")
normal_brain = util.normalizeImage(brain)
dft_brain = util.getDFT(normal_brain)
#util.saveMatrix("Brain_DFT.jpg", dft_brain)
height, width = brain.shape
brain_size = np.array([height, width])

p1mask = aqc.bandPattern(cardiac_size, 15, 128, 35)
p1fmask = util.post_process_image(p1mask)
util.saveImage("p1fmask.jpg", p1fmask)
p1applied = util.applyMask(dft_cardiac, p1mask)
p1image = util.getImage(p1applied)
p1fimage = util.post_process_image(p1image)
util.saveImage('p1_Masked_Image.jpg', p1fimage)

p2mask1 = aqc.bandPattern(cardiac_size, 15, 128, 10)
p2applied1 = util.applyMask(dft_cardiac, p2mask1)
コード例 #3
0
    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)
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)