Mercurial > cortex
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 Filters2 #+author: Robert McIntyre3 #+email: rlm@mit.edu4 #+description: gabor filters in clojure with opencv5 #+keywords: computer vision, jMonkeyEngine3, clojure, opencv6 #+SETUPFILE: ../../aurellem/org/setup.org7 #+INCLUDE: ../../aurellem/org/level-0.org8 #+babel: :mkdirp yes :noweb yes :exports both12 #+name: gabor13 #+begin_src clojure14 (ns cortex.gabor15 (: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-opencv24 "Load the opencv native library. Must be called before any OpenCV25 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 ;;r36 (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 (comment69 ;; these work70 (def i (org.opencv.highgui.Highgui/imread71 "/home/r/proj/cortex/images/dominos.jpg"))73 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" i)74 )75 #+end_src79 * COMMENT Generate Source80 #+begin_src clojure :tangle ../src/cortex/gabor.clj81 <<gabor>>82 #+end_src