Mercurial > cortex
comparison org/gabor.org @ 358:b72fea69b2e1
achieved convolution.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 06 Mar 2013 18:50:35 +0000 |
parents | 90b34cb842de |
children | 744ae7ef9b14 |
comparison
equal
deleted
inserted
replaced
357:90b34cb842de | 358:b72fea69b2e1 |
---|---|
13 #+begin_src clojure | 13 #+begin_src clojure |
14 (ns cortex.gabor | 14 (ns cortex.gabor |
15 (:import org.opencv.core.CvType) | 15 (:import org.opencv.core.CvType) |
16 (:import java.awt.image.BufferedImage) | 16 (:import java.awt.image.BufferedImage) |
17 (:import ij.ImagePlus) | 17 (:import ij.ImagePlus) |
18 (:import org.opencv.core.Mat) | |
18 (:use cortex.sense) | 19 (:use cortex.sense) |
19 (:use cortex.util) | 20 (:use cortex.util) |
20 ) | 21 ) |
21 | 22 |
22 (defn load-opencv | 23 (defn load-opencv |
23 "Load the opencv native library. Must be called before any OpenCV | 24 "Load the opencv native library. Must be called before any OpenCV |
24 stuff is used." | 25 stuff is used." |
25 [] | 26 [] |
26 (clojure.lang.RT/loadLibrary "opencv_java249")) | 27 (clojure.lang.RT/loadLibrary "opencv_java249")) |
27 | 28 |
29 (defn make-kernel [] | |
30 (let [r (org.opencv.core.Mat. 5 5 CvType/CV_32F)] | |
31 (.put r 0 0 (float-array (map (fn [_] (rand)) (range 25)))) | |
32 (println (.dump r)) | |
33 | |
34 ;;r | |
35 | |
36 (org.opencv.core.MatOfFloat. (float-array [1])) | |
37 )) | |
28 | 38 |
29 (defn convolve-practice [] | 39 (defn convolve-practice [] |
30 (let [input "/home/r/proj/cortex/images/dominos.jpg" | 40 (let [input "/home/r/proj/cortex/images/dominos.jpg" |
31 | 41 |
32 | 42 |
33 output "/home/r/ppp.png" | 43 output "/home/r/ppp.png" |
34 | 44 |
35 i (org.opencv.highgui.Highgui/imread input) | 45 i (org.opencv.highgui.Highgui/imread input) |
36 | 46 |
47 kernel (make-kernel) | |
48 | |
49 new-mat (Mat.) | |
50 | |
37 ] | 51 ] |
38 | 52 |
39 | 53 (org.opencv.imgproc.Imgproc/filter2D i new-mat CvType/CV_32F (make-kernel)) |
40 | 54 |
41 | 55 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" new-mat) |
56 | |
42 (view (ImagePlus. input)) | 57 (view (ImagePlus. input)) |
43 (view (ImagePlus. output)) | 58 (view (ImagePlus. output)) |
44 | 59 |
45 )) | 60 )) |
46 | 61 |
47 | 62 |
48 | 63 |
49 | 64 |