Ejemplo n.º 1
0
 def generate_texture(self):
     text = np.zeros((self.size[0], self.size[1]))
     if self.texture_type == BGTextureType.Plain:
         for i in xrange(self.size[0]):
             for j in xrange(self.size[1]):
                 text[i][j] = 0
     elif self.texture_type == BGTextureType.Perlin:
         perlin = PerlinNoiseGenerator(self.texture.shape[0],
                 self.texture.shape[1])
         text = perlin.get_background_noise()
     elif self.texture_type == BGTextureType.HilbertCurve:
         hcurves = HilbertCurves(self.size[0], self.size[1],
                 self.hilbert_level)
         self.texture = hcurves.gen_hilbert_curve()
     if self.corruptor is not None:
         text = self.corruptor(text)
     return text
Ejemplo n.º 2
0
    def __init__(self, gen, collision_check=False, enable_perlin=False):
        self.gen = gen
        self.collision_check = collision_check
        self.use_patch_centers = gen.use_patch_centers

        self.enable_perlin = enable_perlin

        self.w = gen.w
        self.h = gen.h
        self.nin = gen.w * gen.h
        assert gen.out_format == 'array'
        self.out_format = gen.out_format
        self.out_dtype = gen.out_dtype
        self.nout = gen.nout
        self.nclasses = gen.nclasses

        self.n_successes = 0
        self.n_rejections = 0

        if enable_perlin:
            self.perlin_gen = PerlinNoiseGenerator(self.w, self.h, 32)