def setUp(self): self.setup = EvaluationSetup("resources/inputs/", "resources/outputs/") self.mask_size = (1000, 1000) self.actual = None
class SelectiveImageAcquisitionTests(unittest.TestCase): def setUp(self): self.setup = EvaluationSetup("resources/inputs/", "resources/outputs/") self.mask_size = (1000, 1000) self.actual = None def tearDown(self): self.setup = None def test_cartesian_pattern_basic(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.cartesianPattern(self.mask_size, 0.01) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_cartesian_pattern_5_percent(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.cartesianPattern(self.mask_size, 0.05) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_cartesian_pattern_10_percent(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.cartesianPattern(self.mask_size, 0.1) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_cartesian_pattern_30_percent(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.cartesianPattern(self.mask_size, 0.3) 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_circle_acquisition_pattern_when_radius_is_small(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.circlePattern(self.mask_size, 100) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_circle_acquisition_pattern_when_radius_is_half(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.circlePattern(self.mask_size, 500) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_circle_acquisition_pattern_when_radius_is_same_as_image(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.circlePattern(self.mask_size, 1000) 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_ellipse_acquisition_pattern_vertical_ellipse_bigger_than_image( self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.ellipsePattern(self.mask_size, 100, 1500, 0) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_ellipse_acquisition_pattern_centered_horizontal_ellipse(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.ellipsePattern(self.mask_size, 200, 100, 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_band_acquisition_pattern_width_is_large(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 500, 1000, 0) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) 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_band_acquisition_pattern_angle_zero(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 0) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_band_acquisition_pattern_angle_10(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 10) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_band_acquisition_pattern_angle_30(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 30) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_band_acquisition_pattern_angle_45(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 45) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_band_acquisition_pattern_angle_90(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 90) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_band_acquisition_pattern_angle_180(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 180) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_band_acquisition_pattern_angle_270(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 270) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_band_acquisition_pattern_angle_360(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 360) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_band_acquisition_pattern_angle_370(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.bandPattern(self.mask_size, 10, 500, 370) 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)) def test_radial_acquisition_pattern_basic(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.radialPattern(self.mask_size, 10) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_radial_acquisition_pattern_one_ray(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.radialPattern(self.mask_size, 1) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_radial_acquisition_pattern_5(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.radialPattern(self.mask_size, 5) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_radial_acquisition_pattern_180(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.radialPattern(self.mask_size, 180) 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_spiral_acquisition_pattern_sparsity_1(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.spiralPattern(self.mask_size, 1) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_spiral_acquisition_pattern_sparsity_3(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.spiralPattern(self.mask_size, 3) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_spiral_acquisition_pattern_sparsity_5(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) self.actual = aqc.spiralPattern(self.mask_size, 5) 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 setUp(self): self.setup = EvaluationSetup("resources/inputs/", "resources/outputs/")
class Utilities(unittest.TestCase): def setUp(self): self.setup = EvaluationSetup("resources/inputs/", "resources/outputs/") def tearDown(self): self.setup = None def test_loadImage_png(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = util.loadImage("resources/inputs/test_loadImage.png") self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_loadImage_jpg(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = util.loadImage("resources/inputs/test_loadImage.jpg") self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_getDFT(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) input = self.setup.getInputImage('chaplin.png') self.actual = util.getDFT(input) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_getImage(self): expected = self.setup.getExpectedOutput(self._testMethodName) input = self.setup.getInputMatrix('chaplin_dft.npy') self.actual = util.getImage(input) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_applyMask(self): expected = self.setup.getExpectedOutputMatrix(self._testMethodName) dft_image = self.setup.getInputMatrix('chaplin_dft.npy') mask = self.setup.getInputMatrix('mask.npy') self.actual = util.applyMask(dft_image, mask) self.assertTrue(self.setup.matrixEqual(expected, self.actual)) def test_getImage_from_noisy_dft(self): expected = self.setup.getExpectedOutput(self._testMethodName) input = self.setup.getInputMatrix('noisy_dft.npy') self.actual = util.getImage(input) self.assertTrue(self.setup.imagesEqual(expected, self.actual))
def setUp(self): self.setup = EvaluationSetup("resources/inputs/", "resources/outputs/") self.emptymask = (200, 200) self.actual = None
class ImageSynthesisNoise(unittest.TestCase): def setUp(self): self.setup = EvaluationSetup("resources/inputs/", "resources/outputs/") self.emptymask = (200, 200) self.actual = None def tearDown(self): self.setup = None def test_idealLowpassFilter_low_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.idealLowpassFilter(self.emptymask, 10) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_idealLowpassFilter_high_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.idealLowpassFilter(self.emptymask, 150) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_idealLowpassFilter_half_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.idealLowpassFilter(self.emptymask, 100) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_idealHighpassFilter_low_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.idealHighpassFilter(self.emptymask, 10) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_idealHighpassFilter_high_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.idealHighpassFilter(self.emptymask, 150) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_idealHighpassFilter_half_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.idealHighpassFilter(self.emptymask, 100) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_gaussianLowpassFilter_low_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.gaussianLowpassFilter(self.emptymask, 20) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_gaussianLowpassFilter_high_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.gaussianLowpassFilter(self.emptymask, 180) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) 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)) def test_gaussianHighpassFilter_low_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.gaussianHighpassFilter(self.emptymask, 20) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_gaussianHighpassFilter_high_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.gaussianHighpassFilter(self.emptymask, 180) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_gaussianHighpassFilter_half_width(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.gaussianHighpassFilter(self.emptymask, 100) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringLowpassFilter_small_thin_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringLowpassFilter(self.emptymask, 10, 1) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringLowpassFilter_small_thick_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringLowpassFilter(self.emptymask, 10, 5) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringLowpassFilter_half_thin_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringLowpassFilter(self.emptymask, 50, 3) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringLowpassFilter_half_thick_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringLowpassFilter(self.emptymask, 50, 10) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringLowpassFilter_large_thin_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringLowpassFilter(self.emptymask, 100, 3) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringLowpassFilter_large_thick_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringLowpassFilter(self.emptymask, 100, 10) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringHighpassFilter_small_thin_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringHighpassFilter(self.emptymask, 10, 1) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringHighpassFilter_small_thick_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringHighpassFilter(self.emptymask, 10, 5) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringHighpassFilter_half_thin_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringHighpassFilter(self.emptymask, 50, 3) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringHighpassFilter_half_thick_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringHighpassFilter(self.emptymask, 50, 10) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringHighpassFilter_large_thin_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringHighpassFilter(self.emptymask, 100, 3) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_ringHighpassFilter_large_thick_ring(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.ringHighpassFilter(self.emptymask, 100, 10) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_butterworthLowpassFilter_low_width_low_order(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.butterworthLowpassFilter(self.emptymask, 10, 1) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_butterworthLowpassFilter_low_width_high_order(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.butterworthLowpassFilter(self.emptymask, 10, 3) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_butterworthLowpassFilter_high_width_low_order(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.butterworthLowpassFilter(self.emptymask, 50, 1) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_butterworthLowpassFilter_high_width_high_order(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.butterworthLowpassFilter(self.emptymask, 50, 3) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_butterworthHighpassFilter_low_width_low_order(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.butterworthHighpassFilter(self.emptymask, 10, 1) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_butterworthHighpassFilter_low_width_high_order(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.butterworthHighpassFilter(self.emptymask, 10, 3) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_butterworthHighpassFilter_high_width_low_order(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.butterworthHighpassFilter(self.emptymask, 50, 1) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual)) def test_butterworthHighpassFilter_high_width_high_order(self): expected = self.setup.getExpectedOutput(self._testMethodName) self.actual = noise.butterworthHighpassFilter(self.emptymask, 50, 3) self.actual = self.setup.normalizeImage(self.actual) self.assertTrue(self.setup.imagesEqual(expected, self.actual))