comparison transformations/add_background_image.py @ 85:8aadb0f59a64

changed contrast definition for add_background_image
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Wed, 10 Feb 2010 17:47:57 -0500
parents f75f5acad4eb
children
comparison
equal deleted inserted replaced
84:104e0b8a1c70 85:8aadb0f59a64
64 i = random.randint(0, len(self.image_files) - 1) 64 i = random.randint(0, len(self.image_files) - 1)
65 65
66 image = self.load_image(self.bg_image_file + self.image_files[i]) 66 image = self.load_image(self.bg_image_file + self.image_files[i])
67 self.bg_image = self.rand_crop(image) 67 self.bg_image = self.rand_crop(image)
68 maxbg = self.bg_image.max() 68 maxbg = self.bg_image.max()
69 self.bg_image = self.bg_image / maxbg * ( max(maximage - self.contrast/2.0,0.1) ) 69 self.bg_image = self.bg_image / maxbg * ( max(maximage - self.contrast,0.0) )
70 70
71 # set "bg_image" as background to "image", based on a pixels threshold 71 # set "bg_image" as background to "image", based on a pixels threshold
72 def set_bg(self,image): 72 def set_bg(self,image):
73 tensor = numpy.asarray([self.bg_image,image],dtype='float32') 73 tensor = numpy.asarray([self.bg_image,image],dtype='float32')
74 return tensor.max(0) 74 return tensor.max(0)