comparison org/test-creature.org @ 107:53fb379ac678

saving progress
author Robert McIntyre <rlm@mit.edu>
date Sun, 15 Jan 2012 00:40:49 -0700
parents 40e72c6943d8
children 92b857b6145d
comparison
equal deleted inserted replaced
106:40e72c6943d8 107:53fb379ac678
461 (ImageToAwt/convert im false false 0)))))) 461 (ImageToAwt/convert im false false 0))))))
462 462
463 (import ij.process.ImageProcessor) 463 (import ij.process.ImageProcessor)
464 (import java.awt.image.BufferedImage) 464 (import java.awt.image.BufferedImage)
465 465
466 (defprotocol Frame
467 (frame [this]))
468
469 (extend-type BufferedImage
470 Frame
471 (frame [image]
472 (merge
473 (apply
474 hash-map
475 (interleave
476 (doall (for [x (range (.getWidth image)) y (range (.getHeight image))]
477 (vector x y)))
478 (doall (for [x (range (.getWidth image)) y (range (.getHeight image))]
479 (let [data (.getRGB image x y)]
480 (hash-map :r (bit-shift-right (bit-and 0xff0000 data) 16)
481 :g (bit-shift-right (bit-and 0x00ff00 data) 8)
482 :b (bit-and 0x0000ff data)))))))
483 {:width (.getWidth image) :height (.getHeight image)})))
484
485
486 (extend-type ImagePlus
487 Frame
488 (frame [image+]
489 (frame (.getBufferedImage image+))))
490
491
492 (def white -1) 466 (def white -1)
493 467
494 (defn filter-pixels 468 (defn filter-pixels
495 "List the coordinates of all pixels matching pred." 469 "List the coordinates of all pixels matching pred."
496 {:author "Dylan Holmes"} 470 {:author "Dylan Holmes"}
625 (- (apply max (map second verts)) y) 599 (- (apply max (map second verts)) y)
626 ])) 600 ]))
627 601
628 602
629 (defn sensors-in-triangle 603 (defn sensors-in-triangle
630 "find the locations of the sensors within a triangle" 604 "Find the locations of the touch sensors within a triangle in both
631 [image tri] 605 UV and gemoetry relative coordinates."
606 [image mesh tri-index]
607 (let [width (.getWidth image)
608 height (.getHeight image)]
609
610
611
612
632 ) 613 )
633 614
634 615
635 (defn locate-feelers 616 (defn locate-feelers
636 "Search the geometry's tactile UV image for touch sensors, returning 617 "Search the geometry's tactile UV image for touch sensors, returning
1088 (.mult (.getPhysicsRotation control) 1069 (.mult (.getPhysicsRotation control)
1089 (Vector3f. 1 0 0)))))))) 1070 (Vector3f. 1 0 0))))))))
1090 1071
1091 1072
1092 1073
1074 (defprotocol Frame
1075 (frame [this]))
1076
1077 (extend-type BufferedImage
1078 Frame
1079 (frame [image]
1080 (merge
1081 (apply
1082 hash-map
1083 (interleave
1084 (doall (for [x (range (.getWidth image)) y (range (.getHeight image))]
1085 (vector x y)))
1086 (doall (for [x (range (.getWidth image)) y (range (.getHeight image))]
1087 (let [data (.getRGB image x y)]
1088 (hash-map :r (bit-shift-right (bit-and 0xff0000 data) 16)
1089 :g (bit-shift-right (bit-and 0x00ff00 data) 8)
1090 :b (bit-and 0x0000ff data)))))))
1091 {:width (.getWidth image) :height (.getHeight image)})))
1092
1093
1094 (extend-type ImagePlus
1095 Frame
1096 (frame [image+]
1097 (frame (.getBufferedImage image+))))
1098
1099
1093 #+end_src 1100 #+end_src
1094 1101
1095 1102
1096 * COMMENT generate source 1103 * COMMENT generate source
1097 #+begin_src clojure :tangle ../src/cortex/silly.clj 1104 #+begin_src clojure :tangle ../src/cortex/silly.clj