Skip to content

Instantly share code, notes, and snippets.

@dcunited001
Created October 3, 2013 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcunited001/6806317 to your computer and use it in GitHub Desktop.
Save dcunited001/6806317 to your computer and use it in GitHub Desktop.
(ns handwritten-digits.draw
(:use [incanter core charts]))
(declare ^:dynamic sizex)
(declare ^:dynamic sizey)
(declare ^:dynamic nx)
(declare ^:dynamic ny)
(defn get-pixel [x y]
;; translate 2-d coordinates
;; to retrieve from list of unwrapped matrices
(let [n (+ (quot x sizex) (* nx (quot y sizey)))
m (+ (mod x sizex) (* sizex (mod y sizey)))]
(sel data n m)))
(defn draw-digits [data sizex sizey nx ny]
(let [xmax (* sizex nx)
ymax (* sizey ny)]
(binding [sizex sizex
sizey sizey
nx nx
ny ny
data data]
(heat-map get-pixel
0 0 xmax ymax
:title "digits"
:color false))))
;; (heat-map get-pixel 0 0 xmax ymax
;; :title "digits"
;; :color false)))
(defn draw-100-digits [data]
(draw-digits data 28 28 10 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment