changeset 358:b72fea69b2e1

achieved convolution.
author Robert McIntyre <rlm@mit.edu>
date Wed, 06 Mar 2013 18:50:35 +0000
parents 90b34cb842de
children 744ae7ef9b14
files org/gabor.org
diffstat 1 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/gabor.org	Wed Mar 06 18:13:34 2013 +0000
     1.2 +++ b/org/gabor.org	Wed Mar 06 18:50:35 2013 +0000
     1.3 @@ -15,6 +15,7 @@
     1.4    (:import org.opencv.core.CvType)
     1.5    (:import java.awt.image.BufferedImage)
     1.6    (:import ij.ImagePlus)
     1.7 +  (:import org.opencv.core.Mat)
     1.8    (:use cortex.sense)
     1.9    (:use cortex.util)
    1.10    )
    1.11 @@ -25,6 +26,15 @@
    1.12    []
    1.13    (clojure.lang.RT/loadLibrary "opencv_java249"))
    1.14  
    1.15 +(defn make-kernel []
    1.16 +  (let [r (org.opencv.core.Mat. 5 5 CvType/CV_32F)]
    1.17 +    (.put r 0 0 (float-array (map (fn [_] (rand)) (range 25))))
    1.18 +    (println (.dump r))
    1.19 +
    1.20 +    ;;r
    1.21 +
    1.22 +    (org.opencv.core.MatOfFloat. (float-array [1]))
    1.23 +    ))
    1.24  
    1.25  (defn convolve-practice []
    1.26    (let [input "/home/r/proj/cortex/images/dominos.jpg"
    1.27 @@ -33,15 +43,20 @@
    1.28          output "/home/r/ppp.png"
    1.29  
    1.30          i (org.opencv.highgui.Highgui/imread input)
    1.31 -        
    1.32 +
    1.33 +        kernel (make-kernel)
    1.34 +
    1.35 +        new-mat (Mat.)
    1.36 +                
    1.37          ]
    1.38  
    1.39 -
    1.40 -
    1.41 -
    1.42 +    (org.opencv.imgproc.Imgproc/filter2D  i new-mat CvType/CV_32F (make-kernel))
    1.43 +    
    1.44 +    (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" new-mat)
    1.45 +    
    1.46      (view (ImagePlus. input))
    1.47      (view (ImagePlus. output))
    1.48 -
    1.49 +        
    1.50      ))
    1.51  
    1.52