def test_band_acquisition_pattern_invalid_negative_width(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, -4, 1000, 0) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_band_acquisition_pattern_width_larger_than_image(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 2000, 1000, 0) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_ellipse_acquisition_pattern_horizontal_ellipse_bigger_than_image( self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.ellipsePattern(self.mask_size, 1500, 100, 0) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_band_acquisition_pattern_width_is_small(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 30, 500, 0) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_circle_acquisition_pattern_when_radius_is_greater_than_image( self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.circlePattern(self.mask_size, 1200) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_ellipse_acquisition_pattern_centered_vertical_ellipse(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.ellipsePattern(self.mask_size, 100, 200, 0) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_spiral_acquisition_pattern_sparsity_10(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.spiralPattern(self.mask_size, 10) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_cartesian_pattern_60_percent(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.cartesianPattern(self.mask_size, 0.6) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_radial_acquisition_pattern_360(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.radialPattern(self.mask_size, 360) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
def test_band_acquisition_pattern_angle_400(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 400) self.assertTrue(self.setup.matrixEqual(expected, self.actual))
# 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)
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) p2image1 = util.getImage(p2applied1) p2fimage1 = util.post_process_image(p2image1) util.saveImage("p2_Masked_Image_1.jpg", p2fimage1) p2mask2 = aqc.bandPattern(cardiac_size, 10, 171, 135) p2applied2 = util.applyMask(dft_cardiac, p2mask2)
# 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) ################# Part 3 ##################### img_copy2 = util.getDFT(img) #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