Skip to content

Instantly share code, notes, and snippets.

@pieter-van-prooijen
Forked from skuro/nonograms-dojo.clj
Last active September 14, 2016 19:42
Show Gist options
  • Save pieter-van-prooijen/64e8b4bff0230be8133deb1e330f71ca to your computer and use it in GitHub Desktop.
Save pieter-van-prooijen/64e8b4bff0230be8133deb1e330f71ca to your computer and use it in GitHub Desktop.
# fork this gist and provide your solution
(ns nonogram.core
(require [mikera.image.core :as image]
[mikera.image.dither :as dither]))
(defn create-matrix [image-path]
(let [img (-> (image/load-image image-path)
(image/resize 20 20)
(dither/dither (dither/mono-palette-function)))]
(for [x (range 20) y (range 20)]
(image/get-pixel img x y))))
;; Repl output:
> (distinct (create-matrix "resources/banana.bmp"))
(4294967295 4278190080)
@pieter-van-prooijen
Copy link
Author

(ns nonogram.core
(require [mikera.image.core :as image]
[mikera.image.dither :as dither]))

(defn create-matrix [image-path](let [img %28-> %28image/load-image image-path%29
%28image/resize 20 20%29
%28dither/dither %28dither/mono-palette-function%29%29%29]
%28for [x %28range 20%29 y %28range 20%29]
%28image/get-pixel img x y%29%29))

;; repl output:

(distinct (create-matrix "resources/banana.bmp"))
(4294967295 4278190080)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment