changeset 20:6bed8ceb51a9

obtained a linear relation between output and target.
author Robert McIntyre <rlm@mit.edu>
date Mon, 30 Aug 2010 01:01:35 -0400
parents 3b255dcd6c50
children e72220627685
files lib/im4java-1.1.0.jar src/laser/rasterize.clj
diffstat 2 files changed, 38 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file lib/im4java-1.1.0.jar has changed
     2.1 --- a/src/laser/rasterize.clj	Mon Aug 30 00:09:06 2010 -0400
     2.2 +++ b/src/laser/rasterize.clj	Mon Aug 30 01:01:35 2010 -0400
     2.3 @@ -65,7 +65,41 @@
     2.4  ;    (vector (first sorted-row) (last sorted-row))))
     2.5  
     2.6  
     2.7 +(comment
     2.8  
     2.9 +  (import 'org.im4java.core.ConvertCmd)
    2.10 +  (import 'org.im4java.core.IMOperation)
    2.11 +  (import 'org.im4java.core.Stream2BufferedImage)			
    2.12 +
    2.13 +  (def target (.getBufferedImage (ImagePlus. sing)))
    2.14 + (def shiv (IMOperation.))
    2.15 +(.addImage shiv)
    2.16 +(.addImage shiv (into-array String ["png:-"]))
    2.17 +(def conv-shiv (ConvertCmd.))
    2.18 +(def s2b (Stream2BufferedImage.))
    2.19 +(.setOutputConsumer conv-shiv s2b)
    2.20 +(.run conv-shiv shiv (into-array Object [target]))
    2.21 +(def result (.getImage s2b ))
    2.22 +
    2.23 +  )
    2.24 +
    2.25 +(defn mirror [#^ImagePlus img]
    2.26 +  (let [title (.getTitle img)
    2.27 +	target (.getBufferedImage img)
    2.28 +	s2b (Stream2BufferedImage.)
    2.29 +	shiv (doto (IMOperation.)
    2.30 +	       ;(.blur 2.0)
    2.31 +	       (.flip)
    2.32 +	       (.addImage)
    2.33 +	       (.addImage (into-array String ["png:-"])))
    2.34 +	conv-shiv (doto (ConvertCmd.)
    2.35 +		    (.setOutputConsumer s2b))]
    2.36 +
    2.37 +    (.run conv-shiv shiv (into-array Object [target]))
    2.38 +    (ImagePlus. title (.getImage s2b))))
    2.39 +	
    2.40 +    
    2.41 + 
    2.42  (defn row->gcode [{:keys [x-dpi y-dpi margin x-offset y-offset]} forward? row]
    2.43    
    2.44    (let [[x1 y1] (if forward? (last row) (first row))
    2.45 @@ -74,13 +108,14 @@
    2.46      (let [x1 (* x1 (/ x-dpi))
    2.47  	  x2 (* x2 (/ x-dpi))
    2.48  	  y1 (* y1 (/ y-dpi))
    2.49 -	  y2  (* y2(/ y-dpi))]
    2.50 +	  y2 (* y2 (/ y-dpi))]
    2.51  
    2.52      (let [x1 (+ x1 x-offset)
    2.53  	  x2 (+ x2 x-offset)
    2.54  	  y1 (+ y1 y-offset)
    2.55  	  y2 (+ y2 y-offset)]
    2.56 -	  
    2.57 +
    2.58 +      
    2.59            
    2.60        (str (format "G0 X%.3f Y%.3f\n"
    2.61  		   (float x1 )
    2.62 @@ -188,7 +223,7 @@
    2.63  
    2.64  (defn update-state []
    2.65    (def sing "/home/r/kevin/sing.png")
    2.66 -  (def pic (frame-hash (rotate 180 (ImagePlus. sing))))  
    2.67 +  (def pic (frame-hash (mirror (ImagePlus. sing))))
    2.68    (def pic (b&w pic)))
    2.69  
    2.70  (defn compare-gen-fn [n f cmp]