Пример #1
0
    def test_independence(self):
        """Assert the the order of transforms along axes does not matter"""
        x = np.random.standard_normal((10, 11, 3))
        xs1, i1 = dt.compute(x, axes=(0, 1, 2))
        xs2, i2 = dt.compute(x, axes=(2, 1, 0))

        self.assertTrue(np.linalg.norm(xs1 - xs2) == 0.0)
        self.assertTrue(np.linalg.norm(i1[0] - i2[2]) == 0.0)
Пример #2
0
 def dt2d(self,image2d,ax,bx,ay,by):
     '''[score_ans,Ix_ans,Iy_ans] = dt(child.score(:,:,k), child.w(1,k), child.w(2,k), child.w(3,k), child.w(4,k));'''
     nrow,ncol = image2d.shape
     #for x in range(ncol):
     score_x,Ixy = dt.compute(image2d,axes=(0,1),f=dt.L2(-ax,-bx,-ay,-by))
     Ix = Ixy[1]
     Iy = Ixy[0]
     #for y in range(nrow):
         #score,Iy = dt.compute(score_x, axes=(0,0),f=dt.L2(-ay,-by))
     
     return score_x,Ix,Iy
Пример #3
0
    def dt2d(self, image2d, ax, bx, ay, by):
        '''[score_ans,Ix_ans,Iy_ans] = dt(child.score(:,:,k), child.w(1,k), child.w(2,k), child.w(3,k), child.w(4,k));'''
        nrow, ncol = image2d.shape
        #for x in range(ncol):
        score_x, Ixy = dt.compute(image2d,
                                  axes=(0, 1),
                                  f=dt.L2(-ax, -bx, -ay, -by))
        Ix = Ixy[1]
        Iy = Ixy[0]
        #for y in range(nrow):
        #score,Iy = dt.compute(score_x, axes=(0,0),f=dt.L2(-ay,-by))

        return score_x, Ix, Iy
Пример #4
0
def compute_tsdf(grid):

    new_grid = np.copy(grid).astype(np.float64)

    new_grid[np.where(new_grid == 0.)] = 2.
    new_grid[np.where(new_grid == 1.)] = 0.
    new_grid[np.where(new_grid == 2.)] = 1.

    new_grid = 10.e6 * new_grid

    tsdf, i = dt.compute(new_grid)

    tsdf = np.sqrt(tsdf)

    return tsdf
Пример #5
0
 def test_identity(self):
     """Assert that equal potentials are already ground truth"""
     x = np.ones((10, 13))
     xs, i = dt.compute(x)
     self.assertTrue((xs == x).all())
Пример #6
0
 def test_distance_cost(self):
     """Assert that the minimum solution cost > the minimum potential"""
     for n in xrange(100):
         x = np.random.standard_normal((9, 13))
         xs, i = dt.compute(x)
         self.assertTrue(xs.min() >= x.min())