Mercurial > ift6266
diff transformations/add_background_image.py @ 65:ab70fbca513c
Change path to AddBackground and add a image_file attribute (not to do a listdir at each image)
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Tue, 09 Feb 2010 18:31:24 -0500 |
parents | 4d4248f7e2fb |
children | ee6a788557b6 |
line wrap: on
line diff
--- a/transformations/add_background_image.py Tue Feb 09 11:43:09 2010 -0500 +++ b/transformations/add_background_image.py Tue Feb 09 18:31:24 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