comparison clojure/com/aurellem/run/image.clj @ 501:4c43b2b8d3c0

working on confirming accuracy of color map.
author Robert McIntyre <rlm@mit.edu>
date Tue, 12 Jun 2012 10:12:25 -0500
parents 0273c08cd2ff
children e9a63daf680a
comparison
equal deleted inserted replaced
500:0273c08cd2ff 501:4c43b2b8d3c0
221 (partition 221 (partition
222 68 68 [] 222 68 68 []
223 (sort-by 223 (sort-by
224 (fn euclidean-distance [[r g b]] 224 (fn euclidean-distance [[r g b]]
225 (Math/sqrt (+ (* r r) (* g g) (* b b)))) 225 (Math/sqrt (+ (* r r) (* g g) (* b b))))
226 (seq (set (vals gb-color-map)))))))) 226 (filter
227 (fn [[r g b]]
228 (= (max r g b) b ))
229
230 (seq (set (vals gb-color-map)))))))))
227 view (cortex.sense/view-image) 231 view (cortex.sense/view-image)
228 target (File. user-home "proj/vba-clojure/gb-color-map-unique.png")] 232 target (File. user-home "proj/vba-clojure/gb-color-map-unique.png")]
229 (dorun (for [x (range 68) y (range 69)] 233 (dorun (for [x (range 68) y (range 69)]
230 (let [[r g b] (get pix (+ x (* 68 y)) [0 0 0]) 234 (let [[r g b] (get pix (+ x (* 68 y)) [0 0 0])
231 rgb (+ (bit-shift-left r 16) 235 rgb (+ (bit-shift-left r 16)
269 (.next (ImageIO/getImageWritersByFormatName "png")) 273 (.next (ImageIO/getImageWritersByFormatName "png"))
270 (.setOutput (FileImageOutputStream. target)) 274 (.setOutput (FileImageOutputStream. target))
271 (.write (IIOImage. im nil nil)) 275 (.write (IIOImage. im nil nil))
272 (.dispose)) 276 (.dispose))
273 im)) 277 im))
274 278
279
280 (count
281 (filter
282 (fn [[r g b]]
283 (= (max r g b) r ))(set (vals gb-color-map))))