view 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
line wrap: on
line source
1 #+title: Fun with Gabor Filters
2 #+author: Robert McIntyre
3 #+email: rlm@mit.edu
4 #+description: gabor filters in clojure with opencv
5 #+keywords: computer vision, jMonkeyEngine3, clojure, opencv
6 #+SETUPFILE: ../../aurellem/org/setup.org
7 #+INCLUDE: ../../aurellem/org/level-0.org
8 #+babel: :mkdirp yes :noweb yes :exports both
12 #+name: gabor
13 #+begin_src clojure
14 (ns cortex.gabor
15 (:import org.opencv.core.CvType)
16 (:import java.awt.image.BufferedImage)
17 (:import ij.ImagePlus)
18 (:import org.opencv.core.Mat)
19 (:use cortex.sense)
20 (:use cortex.util)
21 )
23 (defn load-opencv
24 "Load the opencv native library. Must be called before any OpenCV
25 stuff is used."
26 []
27 (clojure.lang.RT/loadLibrary "opencv_java249"))
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))
34 ;;r
36 (org.opencv.core.MatOfFloat. (float-array [1]))
37 ))
39 (defn convolve-practice []
40 (let [input "/home/r/proj/cortex/images/dominos.jpg"
43 output "/home/r/ppp.png"
45 i (org.opencv.highgui.Highgui/imread input)
47 kernel (make-kernel)
49 new-mat (Mat.)
51 ]
53 (org.opencv.imgproc.Imgproc/filter2D i new-mat CvType/CV_32F (make-kernel))
55 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" new-mat)
57 (view (ImagePlus. input))
58 (view (ImagePlus. output))
60 ))
68 (comment
69 ;; these work
70 (def i (org.opencv.highgui.Highgui/imread
71 "/home/r/proj/cortex/images/dominos.jpg"))
73 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" i)
74 )
75 #+end_src
79 * COMMENT Generate Source
80 #+begin_src clojure :tangle ../src/cortex/gabor.clj
81 <<gabor>>
82 #+end_src