def test_cube2array2cube(): cube = np.zeros((2, 10, 10)) ns, nx, ny = np.shape(cube) assert nx == ny # condition required nxy = nx * ny cube[1, 2, 2] = 1 array = util.cube2array(cube) cube_new = util.array2cube(array, ns, nxy) assert cube_new[1, 2, 2] == cube[1, 2, 2]
def decomposition(self, image, n_scales): """ 1D starlet transform from starlet coefficients stored in coeffs :param image: 2D image to be decomposed, ndarray with shape (sqrt(n_pixels), sqrt(n_pixels)) :param n_scales: number of decomposition scales :return: reconstructed signal as 1D array of shape (n_scales*n_pixels,) """ if len(image.shape) == 1: image_2d = util.array2image(image) elif len(image.shape) == 2: image_2d = image else: raise ValueError("image has not the right shape (1D or 2D arrays are supported for starlets decomposition)") return util.cube2array(self.decomposition_2d(image_2d, n_scales))
def test_cube2array(): sube = np.zeros((2, 10, 10)) sube[1, 2, 2] = 1 array = util.cube2array(sube) assert array[122] == 1