comparison transformations/add_background_image.py @ 68:ee6a788557b6

Change in add_background_image to load a pickled list of file, not to do a listdir
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Tue, 09 Feb 2010 22:16:22 -0500
parents ab70fbca513c
children 6d87c0df2b0e
comparison
equal deleted inserted replaced
67:5e448ea129b3 68:ee6a788557b6
5 Implementation of random background adding to a specific image 5 Implementation of random background adding to a specific image
6 6
7 Author: Guillaume Sicard 7 Author: Guillaume Sicard
8 ''' 8 '''
9 9
10 import sys, os, random, fnmatch 10 import sys, os, random
11 import cPickle
11 import Image, numpy 12 import Image, numpy
12 13
13 class AddBackground(): 14 class AddBackground():
14 def __init__(self, threshold = 128): 15 def __init__(self, threshold = 128):
15 self.h = 32 16 self.h = 32
16 self.w = 32 17 self.w = 32
17 self.threshold = threshold; 18 self.threshold = threshold;
18 self.bg_image_dir = '/data/lisa/data/ift6266h10/image_net/' 19 self.bg_image_file = '/data/lisa/data/ift6266h10/image_net/filelist.pkl'
19 self.pattern = '*.JPEG' 20 f=open(self.bg_image_file)
20 self.image_files = fnmatch.filter(os.listdir(self.bg_image_dir),self.pattern) 21 self.image_files = cPickle.load(f)
21 22
22 # get threshold value 23 # get threshold value
23 def get_settings_names(self): 24 def get_settings_names(self):
24 return [str(self.threshold)] 25 return [str(self.threshold)]
25 26