def test_double_wedge_filter(self):
    size = 129
    idx1 = (size // 2)
    rad = (size // 4)
    num_proj = 73
    mat = np.zeros((size, size), dtype=np.float32)
    mat[(idx1 - 10):(idx1 + 5), (idx1 + 10):(idx1 + 20)] = np.float32(1.0)
    mat = ndi.gaussian_filter(mat, 1.0)
    sino_360_std = np.zeros((num_proj, size), dtype=np.float32)
    angles = np.linspace(0.0, 360.0, len(sino_360_std), dtype=np.float32)
    for (i, angle) in enumerate(angles):
        sino_360_std[i] = np.sum(ndi.rotate(mat, angle, reshape=False), axis=0)
    sino_360_std = (sino_360_std / size)
    mat = np.zeros((size, size), dtype=np.float32)
    mat[(idx1 - 10):(idx1 + 5), (idx1 + 10):(idx1 + 20)] = np.float32(1.0)
    mat[5:25, 10:25] = np.float32(1.5)
    mat = ndi.gaussian_filter(mat, 1.0)
    sino_360 = np.zeros((num_proj, size), dtype=np.float32)
    angles = np.linspace(0.0, 360.0, len(sino_360), dtype=np.float32)
    for (i, angle) in enumerate(angles):
        sino_360[i] = np.sum(ndi.rotate(mat, angle, reshape=False), axis=0)
    sino_360 = (sino_360 / size)
    sino_360_crop0 = sino_360_std[:, (idx1 - rad):(idx1 + rad)]
    sino_360_crop = sino_360[:, (idx1 - rad):(idx1 + rad)]
    sino_180_crop0 = sino_360_crop0[:((num_proj // 2) + 1)]
    sino_180_crop = sino_360_crop[:((num_proj // 2) + 1)]
    sino_360_filt = filt.double_wedge_filter(sino_360_crop, sino_type='360', iteration=10)
    sino_360_filt = (sino_360_filt * (np.mean(sino_360_crop0) / np.mean(np.abs(sino_360_filt))))
    num1 = np.max(np.abs((sino_360_filt - sino_360_crop0)))
    sino_180_filt = filt.double_wedge_filter(sino_180_crop, center=32.0, sino_type='180', iteration=10)
    sino_180_filt = (sino_180_filt * (np.mean(sino_180_crop0) / np.mean(np.abs(sino_180_filt))))
    num2 = np.max(np.abs((sino_180_filt - sino_180_crop0)))
    self.assertTrue(((num2 <= 0.1) and (num2 <= 0.1)))
def test_double_wedge_filter(self):
    size = 129
    idx1 = (size // 2)
    rad = (size // 4)
    num_proj = 73
    mat = np.zeros((size, size), dtype=np.float32)
    mat[(idx1 - 10):(idx1 + 5), (idx1 + 10):(idx1 + 20)] = np.float32(1.0)
    mat = ndi.gaussian_filter(mat, 1.0)
    sino_360_std = np.zeros((num_proj, size), dtype=np.float32)
    angles = np.linspace(0.0, 360.0, len(sino_360_std), dtype=np.float32)
    for (i, angle) in enumerate(angles):
        sino_360_std[i] = np.sum(ndi.rotate(mat, angle, reshape=False), axis=0)
    sino_360_std = (sino_360_std / size)
    mat = np.zeros((size, size), dtype=np.float32)
    mat[(idx1 - 10):(idx1 + 5), (idx1 + 10):(idx1 + 20)] = np.float32(1.0)
    mat[5:25, 10:25] = np.float32(1.5)
    mat = ndi.gaussian_filter(mat, 1.0)
    sino_360 = np.zeros((num_proj, size), dtype=np.float32)
    angles = np.linspace(0.0, 360.0, len(sino_360), dtype=np.float32)
    for (i, angle) in enumerate(angles):
        sino_360[i] = np.sum(ndi.rotate(mat, angle, reshape=False), axis=0)
    sino_360 = (sino_360 / size)
    sino_360_crop0 = sino_360_std[:, (idx1 - rad):(idx1 + rad)]
    sino_360_crop = sino_360[:, (idx1 - rad):(idx1 + rad)]
    sino_180_crop0 = sino_360_crop0[:((num_proj // 2) + 1)]
    sino_180_crop = sino_360_crop[:((num_proj // 2) + 1)]
    sino_360_filt = filt.double_wedge_filter(sino_360_crop, sino_type='360', iteration=10)
    sino_360_filt = (sino_360_filt * (np.mean(sino_360_crop0) / np.mean(np.abs(sino_360_filt))))
    num1 = np.max(np.abs((sino_360_filt - sino_360_crop0)))
    sino_180_filt = filt.double_wedge_filter(sino_180_crop, center=32.0, sino_type='180', iteration=10)
    sino_180_filt = (sino_180_filt * (np.mean(sino_180_crop0) / np.mean(np.abs(sino_180_filt))))
    num2 = np.max(np.abs((sino_180_filt - sino_180_crop0)))
    self.assertTrue(((num2 <= 0.1) and (num2 <= 0.1)))