Mercurial > cortex
comparison org/gabor.org @ 362:4b229dc028b6
more cleanup.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 07 Mar 2013 03:28:26 +0000 |
parents | 09461dce2e2f |
children | 9fa92af29c3a |
comparison
equal
deleted
inserted
replaced
361:09461dce2e2f | 362:4b229dc028b6 |
---|---|
22 (defn load-opencv | 22 (defn load-opencv |
23 "Load the opencv native library. Must be called before any OpenCV | 23 "Load the opencv native library. Must be called before any OpenCV |
24 stuff is used." | 24 stuff is used." |
25 [] | 25 [] |
26 (clojure.lang.RT/loadLibrary "opencv_java249")) | 26 (clojure.lang.RT/loadLibrary "opencv_java249")) |
27 | |
28 (defn make-kernel [] | |
29 (let [r (org.opencv.core.Mat. 5 5 CvType/CV_32F)] | |
30 (.put r 0 0 (float-array (map (fn [_] (rand)) (range 25)))) | |
31 (println (.dump r)) | |
32 | |
33 r | |
34 | |
35 | |
36 )) | |
37 | 27 |
38 (defn gabor-kernel [sigma aspect-ratio theta wavelength phase-offset] | 28 (defn gabor-kernel [sigma aspect-ratio theta wavelength phase-offset] |
39 | 29 |
40 ;; first, find the size of the kernel which is required | 30 ;; first, find the size of the kernel which is required |
41 (let [square #(expt % 2) | 31 (let [square #(expt % 2) |
95 (.put new-mat 0 0 (float-array scaled-vals)) | 85 (.put new-mat 0 0 (float-array scaled-vals)) |
96 (org.opencv.highgui.Highgui/imwrite output new-mat)))) | 86 (org.opencv.highgui.Highgui/imwrite output new-mat)))) |
97 | 87 |
98 (defn show-kernel [kernel] | 88 (defn show-kernel [kernel] |
99 (let [img-path "/home/r/proj/cortex/tmp/kernel.png"] | 89 (let [img-path "/home/r/proj/cortex/tmp/kernel.png"] |
100 (draw-kernel kernel img-path) | 90 (draw-kernel! kernel img-path) |
101 (view (ImagePlus. output)))) | 91 (view (ImagePlus. output)))) |
102 | 92 |
103 (defn print-kernel [kernel] | 93 (defn print-kernel [kernel] |
104 (println (.dump kernel))) | 94 (println (.dump kernel))) |
105 | 95 |
106 | |
107 | |
108 | |
109 | |
110 | |
111 | |
112 | |
113 | |
114 (defn convolve-practice [] | 96 (defn convolve-practice [] |
115 (let [input "/home/r/proj/cortex/images/dominos.jpg" | 97 (let [input "/home/r/proj/cortex/images/dominos.jpg" |
116 | 98 |
117 | 99 |
118 output "/home/r/ppp.png" | 100 output "/home/r/ppp.png" |
130 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" new-mat) | 112 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" new-mat) |
131 | 113 |
132 (view (ImagePlus. input)) | 114 (view (ImagePlus. input)) |
133 (view (ImagePlus. output)))) | 115 (view (ImagePlus. output)))) |
134 | 116 |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | |
141 (comment | |
142 ;; these work | |
143 (def i (org.opencv.highgui.Highgui/imread | |
144 "/home/r/proj/cortex/images/dominos.jpg")) | |
145 | |
146 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" i) | |
147 ) | |
148 #+end_src | 117 #+end_src |
149 | 118 |
150 | 119 |
151 | 120 |
152 * COMMENT Generate Source | 121 * COMMENT Generate Source |