Mercurial > cortex
changeset 92:e70ec4bba96b
saving progress...
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 09 Jan 2012 06:05:29 -0700 |
parents | 2bcc7636cfea |
children | 7b739503836a |
files | assets/Models/creature1/try-again.blend org/test-creature.org |
diffstat | 2 files changed, 3 insertions(+), 105 deletions(-) [+] |
line wrap: on
line diff
1.1 Binary file assets/Models/creature1/try-again.blend has changed
2.1 --- a/org/test-creature.org Mon Jan 09 06:02:06 2012 -0700 2.2 +++ b/org/test-creature.org Mon Jan 09 06:05:29 2012 -0700 2.3 @@ -378,15 +378,11 @@ 2.4 (frame [image+] 2.5 (frame (.getBufferedImage image+)))) 2.6 2.7 -(defn rgb->int [r g b] 2.8 - (+ (bit-shift-left r 16) 2.9 - (bit-shift-left g 8) 2.10 - b)) 2.11 - 2.12 - 2.13 +(def white -1) 2.14 2.15 (defn filter-pixels 2.16 "List the coordinates of all pixels matching pred." 2.17 + {:author "Dylan Holmes"} 2.18 [pred #^ImageProcessor ip] 2.19 (let 2.20 [width (.getWidth ip) 2.21 @@ -400,109 +396,11 @@ 2.22 :else (recur (inc x) y matches))) 2.23 0 0 []))) 2.24 2.25 - 2.26 - 2.27 - 2.28 - 2.29 -(defn filter-pixels* 2.30 - [pred #^ImageProcessor ip] 2.31 - (let 2.32 - [width (.getWidth ip) 2.33 - height (.getHeight ip) 2.34 - coords (ref []) 2.35 - process 2.36 - (fn [[start end]] 2.37 - (loop [i start] 2.38 - (if (<= i end) 2.39 - (do 2.40 - (let [column (rem i height) 2.41 - row (unchecked-divide i width)] 2.42 - (if (pred (.getPixel ip row column)) 2.43 - (dosync (ref-set 2.44 - coords 2.45 - (conj @coords (Vector2f. column row))))) 2.46 - 2.47 - (recur (inc i))))))) 2.48 - ] 2.49 - 2.50 - 2.51 - (dorun 2.52 - (pmap process (partition 2.53 - 2 2.54 - (conj (vec (range 0 (* width height) 100)) 2.55 - (* width height))))) 2.56 - @coords)) 2.57 - 2.58 - 2.59 - 2.60 -(comment 2.61 - ((-> 2.62 - f 2.63 - (partial x) 2.64 - (partial y) 2.65 - (partial z)))) 2.66 - 2.67 -(defn filter-pixels** 2.68 - [pred #^ImageProcessor ip] 2.69 - (let [width (.getWidth ip) 2.70 - height (.getHeight ip)] 2.71 - ((fn f [x1 x2 y1 y2] 2.72 - (println x1) 2.73 - (if 2.74 - (and 2.75 - (= x1 (dec x2)) 2.76 - (= y1 (dec y2))) 2.77 - (if (pred (.getPixel ip x1 y1)) 2.78 - [[x1 y1]] 2.79 - []) 2.80 - (let 2.81 - [xm (+ x1 (/ (- x2 x1) 2)) 2.82 - ym (+ y1 (/ (- y2 y1) 2))] 2.83 - (apply concat 2.84 - (pvalues 2.85 - ;;(f x1 xm y1 ym) 2.86 - ;;(f xm x2 y1 ym) 2.87 - ;;(f x1 xm ym y2) 2.88 - (f xm x2 ym y2)))))) 2.89 - 0 width 0 height))) 2.90 - 2.91 - 2.92 - 2.93 - 2.94 - 2.95 - 2.96 - 2.97 - 2.98 -(defn white-coordinates* 2.99 - [#^ImageProcessor ip] 2.100 - (filter-pixels** #(== % -1) ip)) 2.101 - 2.102 - 2.103 (defn white-coordinates 2.104 "List the coordinates of all the white pixels in an image." 2.105 [#^ImageProcessor ip] 2.106 - (let [height (.getHeight ip) 2.107 - width (.getWidth ip) 2.108 - coords (transient [])] 2.109 - (dorun 2.110 - (for [x (range width) 2.111 - y (range height)] 2.112 - (let [pixel (.getPixel ip x y)] 2.113 - (if (= pixel -1) 2.114 - (conj! coords (Vector2f. x y)))))) 2.115 - (persistent! coords))) 2.116 - 2.117 - 2.118 - 2.119 - 2.120 - 2.121 - 2.122 + (filter-pixels #(= % white) ip)) 2.123 2.124 - 2.125 -(def white {:r 255, :g 255, :b 255}) 2.126 -(def black {:r 0, :g 0, :b 0}) 2.127 - 2.128 - 2.129 (defn same-side? [p1 p2 ref p] 2.130 (<= 2.131 0