# HG changeset patch # User Robert McIntyre # Date 1283144495 14400 # Node ID 6bed8ceb51a9110172acdc4761dd03532edcba42 # Parent 3b255dcd6c500b2f3212ae7e695ee17e789a33e5 obtained a linear relation between output and target. diff -r 3b255dcd6c50 -r 6bed8ceb51a9 lib/im4java-1.1.0.jar Binary file lib/im4java-1.1.0.jar has changed diff -r 3b255dcd6c50 -r 6bed8ceb51a9 src/laser/rasterize.clj --- a/src/laser/rasterize.clj Mon Aug 30 00:09:06 2010 -0400 +++ b/src/laser/rasterize.clj Mon Aug 30 01:01:35 2010 -0400 @@ -65,7 +65,41 @@ ; (vector (first sorted-row) (last sorted-row)))) +(comment + (import 'org.im4java.core.ConvertCmd) + (import 'org.im4java.core.IMOperation) + (import 'org.im4java.core.Stream2BufferedImage) + + (def target (.getBufferedImage (ImagePlus. sing))) + (def shiv (IMOperation.)) +(.addImage shiv) +(.addImage shiv (into-array String ["png:-"])) +(def conv-shiv (ConvertCmd.)) +(def s2b (Stream2BufferedImage.)) +(.setOutputConsumer conv-shiv s2b) +(.run conv-shiv shiv (into-array Object [target])) +(def result (.getImage s2b )) + + ) + +(defn mirror [#^ImagePlus img] + (let [title (.getTitle img) + target (.getBufferedImage img) + s2b (Stream2BufferedImage.) + shiv (doto (IMOperation.) + ;(.blur 2.0) + (.flip) + (.addImage) + (.addImage (into-array String ["png:-"]))) + conv-shiv (doto (ConvertCmd.) + (.setOutputConsumer s2b))] + + (.run conv-shiv shiv (into-array Object [target])) + (ImagePlus. title (.getImage s2b)))) + + + (defn row->gcode [{:keys [x-dpi y-dpi margin x-offset y-offset]} forward? row] (let [[x1 y1] (if forward? (last row) (first row)) @@ -74,13 +108,14 @@ (let [x1 (* x1 (/ x-dpi)) x2 (* x2 (/ x-dpi)) y1 (* y1 (/ y-dpi)) - y2 (* y2(/ y-dpi))] + y2 (* y2 (/ y-dpi))] (let [x1 (+ x1 x-offset) x2 (+ x2 x-offset) y1 (+ y1 y-offset) y2 (+ y2 y-offset)] - + + (str (format "G0 X%.3f Y%.3f\n" (float x1 ) @@ -188,7 +223,7 @@ (defn update-state [] (def sing "/home/r/kevin/sing.png") - (def pic (frame-hash (rotate 180 (ImagePlus. sing)))) + (def pic (frame-hash (mirror (ImagePlus. sing)))) (def pic (b&w pic))) (defn compare-gen-fn [n f cmp]