Exemplo n.º 1
0
    def test_shift_points5(self):
        data = [
            Node(id=0, location=np.array([3, 0])),
            Node(id=1, location=np.array([3, 2])),
            Node(id=2, location=np.array([3, 4])),
            Node(id=3, location=np.array([3, 6])),
            Node(id=4, location=np.array([3, 8])),
        ]
        spec = GraphSpec(Roi(offset=(0, 0), shape=(15, 10)))
        points = Graph(data, [], spec)
        request_roi = Roi(offset=(3, 0), shape=(9, 10))
        shift_array = np.array([[3, 0], [-3, 0], [0, 0], [-3, 0], [3, 0]],
                               dtype=int)

        lcm_voxel_size = Coordinate((3, 2))
        shifted_data = [
            Node(id=0, location=np.array([6, 0])),
            Node(id=2, location=np.array([3, 4])),
            Node(id=4, location=np.array([6, 8])),
        ]
        result = ShiftAugment.shift_points(
            points,
            request_roi,
            shift_array,
            shift_axis=1,
            lcm_voxel_size=lcm_voxel_size,
        )
        # print("test 4", result.data, shifted_data)
        self.assertTrue(self.points_equal(result.nodes, shifted_data))
        self.assertTrue(result.spec == GraphSpec(request_roi))
Exemplo n.º 2
0
    def test_shift_points2(self):
        data = [Node(id=1, location=np.array([0, 1]))]
        spec = GraphSpec(Roi(offset=(0, 0), shape=(5, 5)))
        points = Graph(data, [], spec)
        request_roi = Roi(offset=(0, 1), shape=(5, 3))
        shift_array = np.array([[0, 0], [0, -1], [0, 0], [0, 0], [0, 1]],
                               dtype=int)
        lcm_voxel_size = Coordinate((1, 1))

        result = ShiftAugment.shift_points(
            points,
            request_roi,
            shift_array,
            shift_axis=0,
            lcm_voxel_size=lcm_voxel_size,
        )
        # print("test 2", result.data, data)
        self.assertTrue(self.points_equal(result.nodes, data))
        self.assertTrue(result.spec == GraphSpec(request_roi))