def test_igo_channels(): n_cases = 3 channels = np.random.randint(1, 10, [n_cases, 1]) for i in range(n_cases): image = Image(np.random.randn(channels[i, 0], 40, 40)) igo_img = igo(image) igo2_img = igo(image, double_angles=True) assert_allclose(igo_img.shape, image.shape) assert_allclose(igo2_img.shape, image.shape) assert_allclose(igo_img.n_channels, 2 * channels[i, 0]) assert_allclose(igo2_img.n_channels, 4 * channels[i, 0])
def test_igo_values(): image = Image([[1.0, 2.0], [2.0, 1.0]]) igo_img = igo(image) res = np.array( [[[0.70710678, 0.70710678], [-0.70710678, -0.70710678]], [[0.70710678, -0.70710678], [0.70710678, -0.70710678]]] ) assert_allclose(igo_img.pixels, res) image = Image([[0.0, 0.0], [0.0, 0.0]]) igo_img = igo(image) res = np.array([[[0.0, 0.0], [0.0, 0.0]], [[1.0, 1.0], [1.0, 1.0]]]) assert_allclose(igo_img.pixels, res)
def test_igo_values(): image = Image([[1.0, 2.0], [2.0, 1.0]]) igo_img = igo(image) res = np.array([ [[0.70710678, 0.70710678], [-0.70710678, -0.70710678]], [[0.70710678, -0.70710678], [0.70710678, -0.70710678]], ]) assert_allclose(igo_img.pixels, res) image = Image([[0.0, 0.0], [0.0, 0.0]]) igo_img = igo(image) res = np.array([[[0.0, 0.0], [0.0, 0.0]], [[1.0, 1.0], [1.0, 1.0]]]) assert_allclose(igo_img.pixels, res)
def test_igo_values(): image = Image([[1, 2], [2, 1]]) igo_img = igo(image) res = np.array([ [[math.cos(math.radians(45)), math.sin(math.radians(45))], [math.cos(math.radians(90+45)), math.sin(math.radians(90+45))]], [[math.cos(math.radians(-45)), math.sin(math.radians(-45))], [math.cos(math.radians(180+45)), math.sin(math.radians(180+45))]]]) assert_allclose(igo_img.pixels, res) image = Image([[0, 0], [0, 0]]) igo_img = igo(image) res = np.array([[[1., 0.], [1., 0.]], [[1., 0.], [1., 0.]]]) assert_allclose(igo_img.pixels, res)
def test_igo_values(): image = Image([[1, 2], [2, 1]]) igo_img = igo(image) res = np.array( [[[math.cos(math.radians(45)), math.sin(math.radians(45))], [math.cos(math.radians(90 + 45)), math.sin(math.radians(90 + 45))]], [[math.cos(math.radians(-45)), math.sin(math.radians(-45))], [math.cos(math.radians(180 + 45)), math.sin(math.radians(180 + 45))]]]) assert_allclose(igo_img.pixels, res) image = Image([[0, 0], [0, 0]]) igo_img = igo(image) res = np.array([[[1., 0.], [1., 0.]], [[1., 0.], [1., 0.]]]) assert_allclose(igo_img.pixels, res)
def custom_double_igo(image): return igo(igo(image))