comparison clojure/com/aurellem/run/image.clj @ 503:4703b74f1fb1

saving progress
author Robert McIntyre <rlm@mit.edu>
date Thu, 14 Jun 2012 00:47:15 -0500
parents e9a63daf680a
children 81e43f0350db
comparison
equal deleted inserted replaced
502:e9a63daf680a 503:4703b74f1fb1
302 (defn gb-tiles [^BufferedImage image] 302 (defn gb-tiles [^BufferedImage image]
303 (for [tile (range 360)] 303 (for [tile (range 360)]
304 (for [x (range 8) y (range 8)] 304 (for [x (range 8) y (range 8)]
305 (vga-rgb->gb-rgb 305 (vga-rgb->gb-rgb
306 (rgb->triplet 306 (rgb->triplet
307 (.getRGB image (+ x (rem (* tile 8 8) 160)) 307 (.getRGB image (+ x (* 8 (rem tile 20)))
308 (+ y (int (/ (* tile 8 8) 144))))))))) 308 (+ y (* 8 (int (/ tile 20))))))))))
309
310 (defn tile->palette [tile]
311 (sort (set tile)))
312
313 (require 'clojure.set)
314
315 (defn absorb-contract [objs]
316 (reduce
317 (fn [accepted new-element]
318 (if (some
319 (fn [obj]
320 (clojure.set/subset? (set new-element) (set obj)))
321 accepted)
322 accepted
323 (conj accepted new-element)))
324 []
325 (sort-by (comp - count) objs)))
326
327 (defn absorb-combine-4 [objs]
309 328
329
330 )
331
332 (defn palettes [^BufferedImage image]
333 (let [palettes (map tile->palette (gb-tiles image))
334 unique-palettes (absorb-contract (set palettes))]
335 unique-palettes))
336
337
338
339
340
341
342
310 343
311 (defn display-image-kernel [^BufferedImage image] 344 (defn display-image-kernel [^BufferedImage image]
312 345
313 346
314 347