Changeset 23
- Timestamp:
- 09/24/07 15:52:23 (1 year ago)
- Files:
-
- baseline/b1.jpg (modified) (previous)
- baseline/b2.jpg (modified) (previous)
- baseline/b3.jpg (added)
- baseline/b4.jpg (added)
- baseline/b5.jpg (added)
- baseline/b6.jpg (added)
- baseline/b7.jpg (added)
- config.py (modified) (1 diff)
- mactorii.py (modified) (9 diffs)
- wavelet.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
config.py
r21 r23 20 20 trash_dir = ".mactorii-trash" 21 21 text_yoffset = 3 22 baselines=("baseline/b1.jpg", "baseline/b2.jpg") 22 baselines=( #"baseline/b1.jpg", "baseline/b2.jpg", "baseline/b5.jpg", 23 "baseline/b3.jpg", "baseline/b4.jpg", "baseline/b6.jpg","baseline/b7.jpg") 23 24 24 25 def main(): mactorii.py
r21 r23 28 28 win = None 29 29 images = dict() 30 baselines = [] 31 30 32 renderables = None 31 33 32 34 yoffset = 0 33 35 xoffset = 0 36 xmotion = 0 37 34 38 rows = 1 35 xmotion = 0 39 cols = 1 36 40 37 41 clickx = 0 … … 93 97 global last_deleted 94 98 global fps_display 95 99 96 100 if symbol == key.LEFT: 97 101 xmotion = 10 … … 123 127 else: 124 128 fps_display = clock.ClockDisplay() 129 130 if symbol == key.C: 131 cluster_renderables() 132 133 if symbol == key.Q: 134 exit(0) 135 125 136 def strip_width(): 126 137 """returns the width of the strip in pixels""" … … 133 144 global xoffset 134 145 global rows 135 146 global cols 147 136 148 p = xoffset/strip_width() 137 149 138 150 rows = int(height/config.crop_size) 151 cols = math.floor(len(files)/rows)+1 139 152 140 153 yoffset = (height - rows * config.crop_size)/2 … … 143 156 # compute the new xoffset 144 157 xoffset = p * strip_width() 158 159 def signature_compare(sig1, sig2): 160 score=[] 161 for b in xrange(3): 162 score.append(config.weights[b]*len(sig1[b].intersection(sig2[b]))) 163 164 return sum(score) 165 166 def cluster_func(item): 167 global cols 168 global rows 169 170 item_sig = item[1][2] 171 172 mul = 113 173 score = 0 174 for sig in baselines: 175 score += signature_compare(sig, item_sig) 176 score*=mul 177 178 return score 179 180 def cluster_renderables(): 181 """cluster renderables by their score against the 2 base lines""" 182 global images 183 global renderables 184 185 renderables = images.items() 186 187 # sort the renderables 188 renderables.sort(key=cluster_func) 189 190 #for i, r in enumerate(renderables): 191 145 192 146 193 def update_renderables(): … … 153 200 if selected != None: 154 201 renderables.sort(key=sort_func) 155 156 return renderables 157 202 158 203 def sort_func(item): 159 204 assert selected != None … … 162 207 item_sig = item[1][2] 163 208 164 score = [] 165 for b in xrange(3): 166 score.append(config.weights[b]*len(selected_sig[b].intersection(item_sig[b]))) 167 return -sum(score) 168 209 return -signature_compare(selected_sig, item_sig) 210 211 def load_baseline(file): 212 """loads baseline pictures""" 213 global baselines 214 215 print "processing baseline: %s"%(file) 216 wi = wavelet.open(file) 217 sig = wi.signature() 218 baselines.append(sig) 219 169 220 def load_file(file): 170 221 """loads the files given in the command line""" … … 252 303 global yoffset 253 304 global rows 305 global cols 254 306 global files 255 307 global win … … 264 316 global fps_display 265 317 318 for baseline in config.baselines: 319 load_baseline(baseline) 320 266 321 files = sys.argv[1:] 267 322 for file in files: 268 323 load_file(file) 269 324 270 for baseline in config.baselines 325 update_renderables() 326 271 327 win = window_setup() 272 328 ft = font_setup() 329 trash_setup() 273 330 274 331 assert win != None 275 332 assert ft != None 276 333 277 trash_setup()278 279 334 image_pattern = pyglet_image.SolidColorImagePattern((0,0,0,1)) 280 335 281 336 clock.set_fps_limit(30) 282 337 283 renderables = update_renderables()284 338 285 339 while not win.has_exit: wavelet.py
r8 r23 82 82 # sort the values to determine upper and lower cut offs for significance 83 83 tmp.sort() 84 lower = tmp[config.taps/2] 85 upper = tmp[length-config.taps/2] 84 85 if length > config.taps: 86 lower = tmp[config.taps/2] 87 upper = tmp[length-config.taps/2] 88 else: 89 lower = tmp[length/4] 90 upper = tmp[length-length/4] 86 91 87 92 # keep up to config.taps number of significant values, storing only their
