Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
combinating ppm images
(defn process []
(let [file-data (IOUtils/toByteArray (io/input-stream "resources/img1.ppm"))
ppm-head (subvec (vec file-data) 0 32)
img-data (partition 3 (subvec (vec file-data) 32))
file-data2 (IOUtils/toByteArray (io/input-stream "resources/img2.ppm"))
img-data2 (partition 3 (subvec (vec file-data2) 32))]
(let [result (map #(map (fn [n] (/ n 2)) (map + %1 %2)) img-data img-data2) ;(r/fold (r/monoid into vector) conj (r/map #(/ (+ % %) 2) img-data img-data2))
result-data (flatten result)
ba (byte-array (concat ppm-head result-data))]
(IOUtils/write ba (io/output-stream "resources/out.ppm")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment