# HG changeset patch # User fsavard # Date 1264803364 18000 # Node ID b67d729ebfe3e86faf18d1cdf8463d80827c8eb2 # Parent e5ee2c9a9517bd3a89a286483deeb49a28fb526f Adapted to avoid saving parameters completely determined by complexity diff -r e5ee2c9a9517 -r b67d729ebfe3 transformations/local_elastic_distortions.py --- a/transformations/local_elastic_distortions.py Fri Jan 29 14:12:09 2010 -0500 +++ b/transformations/local_elastic_distortions.py Fri Jan 29 17:16:04 2010 -0500 @@ -106,7 +106,12 @@ idx = numpy.random.randint(0, len(self.precomputed_params)) self.current_params = self.precomputed_params[idx] - return self.current_params.alpha_sigma() + # don't return anything, to avoid storing deterministic parameters + return [] # self.current_params.alpha_sigma() + + def get_parameters_determined_by_complexity(self, complexity): + tmp_params = self._initialize_new_params(complexity) + return tmp_params.alpha_sigma() # adapted from http://blenderartists.org/forum/showthread.php?t=163361 def _gen_gaussian_kernel(self, sigma): @@ -147,23 +152,25 @@ return params.alpha * field - def _initialize_new_params(self): + def _initialize_new_params(self, complexity=None): + if not complexity: + complexity = self.current_complexity + params = ElasticDistortionParams(self.image_size) - cpx = self.current_complexity # pour faire progresser la complexité un peu plus vite # tout en gardant les extrêmes de 0.0 et 1.0 - cpx = cpx ** (1./3.) + complexity = complexity ** (1./3.) # the smaller the alpha, the closest the pixels are fetched # a max of 10 is reasonable - params.alpha = cpx * 10.0 + params.alpha = complexity * 10.0 # the bigger the sigma, the smoother is the distortion # max of 1 is "reasonable", but produces VERY noisy results # And the bigger the sigma, the bigger the blur kernel, and the # slower the field generation, btw. - params.sigma = 10.0 - (7.0 * cpx) + params.sigma = 10.0 - (7.0 * complexity) return params @@ -308,7 +315,8 @@ img = _load_image(imgpath) dist = LocalElasticDistorter((32,32)) print dist.regenerate_parameters(0.5) - img = dist.distort_image(img) + img = dist.transform_image(img) + print dist.get_parameters_determined_by_complexity(0.4) pylab.imshow(img) pylab.show() @@ -419,8 +427,9 @@ import os.path #_distorter_tests() #_benchmark() - #_specific_test() + _specific_test() #_complexity_tests() - _complexity_benchmark() + #_complexity_benchmark() +