# HG changeset patch # User Xavier Glorot # Date 1265759135 18000 # Node ID bf83682c827be33a9ce4a71cd8106aa597b5488d # Parent ab70fbca513c76d3a2447f0a7f96183e553dd7cd# Parent 1afa95285b9c3cd6071de35e4ddf3f1143bd24b8 merge diff -r 1afa95285b9c -r bf83682c827b transformations/add_background_image.py --- a/transformations/add_background_image.py Tue Feb 09 18:25:50 2010 -0500 +++ b/transformations/add_background_image.py Tue Feb 09 18:45:35 2010 -0500 @@ -15,8 +15,9 @@ self.h = 32 self.w = 32 self.threshold = threshold; - self.bg_image_dir = './images/' - self.pattern = '*.jpg' + self.bg_image_dir = '/data/lisa/data/ift6266h10/image_net/' + self.pattern = '*.JPEG' + self.image_files = fnmatch.filter(os.listdir(self.bg_image_dir),self.pattern) # get threshold value def get_settings_names(self): @@ -51,11 +52,9 @@ # select a random background image from "bg_image_dir" and crops it def rand_bg_image(self): - files = os.listdir(self.bg_image_dir) - image_files = fnmatch.filter(files, self.pattern) - i = random.randint(0, len(image_files) - 1) + i = random.randint(0, len(self.image_files) - 1) - image = self.load_image(self.bg_image_dir + image_files[i]) + image = self.load_image(self.bg_image_dir + self.image_files[i]) self.bg_image = self.rand_crop(image) # set "bg_image" as background to "image", based on a pixels threshold