Пример #1
0
 def sample_grid_outside(self, nb_points = 1000, procentage = 0.1):
     """ Similar to sample_grid, however this samples from a extension of the
         image domain where procentage * image domain is added around the
         original image domain
     """
     x_ext = procentage * (self.maxbound[0] - self.minbound[0])
     y_ext = procentage * (self.maxbound[1] - self.minbound[1])
     return create_grid([self.minbound[0] - x_ext, self.minbound[1] - y_ext],
                        [self.maxbound[0] + x_ext, self.maxbound[1] + y_ext], 
                        [nb_points, nb_points])
Пример #2
0
def get_transformer_init_weights(n_units, transformer_name='affine'):
    """ Get weights that initialize a given transformer to the identity transformation """
    dim = get_transformer_dim(transformer_name)
    kernel = {'affine': np.zeros((n_units, dim), dtype=np.float32),
              'affinediffeo': np.zeros((n_units, dim), dtype=np.float32),
              'homografy': np.zeros((n_units, dim), dtype=np.float32),
              'CPAB': np.zeros((n_units, dim), dtype=np.float32),
              'TPS': np.zeros((n_units, dim), dtype=np.float32)}

    bias = {'affine': np.array([1,0,0,0,1,0], dtype=np.float32),
            'affinediffeo': np.zeros((dim,), dtype=np.float32),
            'homografy': np.array([1,0,0,0,1,0,0,0,1], dtype=np.float32),
            'CPAB': np.zeros((dim,), dtype=np.float32),
            'TPS': create_grid([-1,-1],[1,1],[8,8]).T.flatten()}

    return (kernel[transformer_name], bias[transformer_name])
Пример #3
0
 def sample_grid_image(self, imagesize):
     """ Similar to sample_grid, just with varing sample size in x,y direction """
     return create_grid(self.minbound, self.maxbound, imagesize)
Пример #4
0
 def sample_grid(self, nb_points = 1000):
     """ Samples nb_points in both directions within the image domain and 
         returns a matrix of size (nb_points^2, 2), where each row is point
     """
     return create_grid(self.minbound, self.maxbound, [nb_points, nb_points])