changeset 361:09461dce2e2f

cleanup.
author Robert McIntyre <rlm@mit.edu>
date Thu, 07 Mar 2013 03:27:42 +0000
parents fc5bb270596a
children 4b229dc028b6
files org/gabor.org
diffstat 1 files changed, 17 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/gabor.org	Thu Mar 07 03:12:25 2013 +0000
     1.2 +++ b/org/gabor.org	Thu Mar 07 03:27:42 2013 +0000
     1.3 @@ -17,8 +17,7 @@
     1.4    (:import ij.ImagePlus)
     1.5    (:import org.opencv.core.Mat)
     1.6    (:use cortex.sense)
     1.7 -  (:use cortex.util)
     1.8 -  )
     1.9 +  (:use cortex.util))
    1.10  
    1.11  (defn load-opencv
    1.12    "Load the opencv native library. Must be called before any OpenCV
    1.13 @@ -55,10 +54,12 @@
    1.14                        (+ (* 2 Math/PI (/ x' wavelength))
    1.15                           phase-offset))))
    1.16  
    1.17 -        half-width (max
    1.18 -                    (int (* 5 (/ sigma aspect-ratio)))
    1.19 -                    (int (* 5 sigma))
    1.20 -                    (int (* 5 (/ aspect-ratio sigma))))
    1.21 +        half-width
    1.22 +        (let [std-dev-capture 5]
    1.23 +          (max
    1.24 +           (int (* std-dev-capture (/ sigma aspect-ratio)))
    1.25 +           (int (* std-dev-capture sigma))
    1.26 +           (int (* std-dev-capture (/ aspect-ratio sigma)))))
    1.27  
    1.28          grid (let [axis (range (- half-width) (inc half-width))]
    1.29                 (for [y (reverse axis) x axis] (vector x y)))
    1.30 @@ -70,18 +71,13 @@
    1.31  
    1.32          mat-width (+ 1 (* 2 half-width))
    1.33          mat (Mat. mat-width mat-width CvType/CV_32F)]
    1.34 -
    1.35      
    1.36      (.put mat 0 0 (float-array (map gabor grid)))
    1.37 -    mat
    1.38 +    mat))
    1.39  
    1.40 -    ;;(map gabor grid)
    1.41 -    
    1.42 -    ))
    1.43  
    1.44 -
    1.45 -(defn show-kernel [kernel]
    1.46 -  (let [output "/home/r/proj/cortex/tmp/kernel.png"
    1.47 +(defn draw-kernel! [kernel img-path]
    1.48 +  (let [output img-path
    1.49          size (.size kernel)
    1.50          width (int (.width size))
    1.51          height (int (.height size))
    1.52 @@ -97,8 +93,12 @@
    1.53            scaled-vals (map #(* 255 (- % low) (/ (- high low))) vals)
    1.54            new-mat (Mat. height width CvType/CV_32F)]
    1.55        (.put new-mat 0 0 (float-array scaled-vals))
    1.56 -      (org.opencv.highgui.Highgui/imwrite output new-mat)
    1.57 -      (view (ImagePlus. output)))))
    1.58 +      (org.opencv.highgui.Highgui/imwrite output new-mat))))
    1.59 +
    1.60 +(defn show-kernel [kernel]
    1.61 +  (let [img-path "/home/r/proj/cortex/tmp/kernel.png"]
    1.62 +    (draw-kernel kernel img-path)
    1.63 +    (view (ImagePlus. output))))
    1.64  
    1.65  (defn print-kernel [kernel]
    1.66    (println (.dump kernel)))
    1.67 @@ -130,9 +130,7 @@
    1.68      (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" new-mat)
    1.69      
    1.70      (view (ImagePlus. input))
    1.71 -    (view (ImagePlus. output))
    1.72 -        
    1.73 -    ))
    1.74 +    (view (ImagePlus. output))))
    1.75  
    1.76    
    1.77