img <- readImage "file.png"
-- instead of this?
t <- readImage "file.png"
let img = t
Why not this:
map (y!!) x
foldr ((:).(y!!)) [] x -- instead of this?
Note that a way of reading fold g [] is that replaces the list constructor (:) (aka cons) with g. So (:) as argument of fold is probably not idiomatic, since foldr (:) [] is the same as id.
Very neat. Makes me kind of embarrassed that I never got around to actually solving this challenge. I've had the web page open on my laptop since it first showed up on HN.
So is this challenge over? I submitted an entry using Canvas as well but allowed users to drop image in from their desktop (only works in Chrome/Firefox though). Haven't heard from anyone at Instagram.
I solved it in ocaml, I only had this development environment this week end but it was fun. I didn't posted it on my blog but if someone wants it, just ask ;)
While I didn't look at how he did it, if I were to write something to do this, I would first locate each slice of the image. This could be accomplished using a rudimentary edge detection algorithm ( ie starting from the left, compare each column of pixels with the next, any large differences of course means an edge ). After that I might assign a weighted value to each edge of a slice, and then sort based upon those values.
https://github.com/Mgccl/mgccl-haskell/blob/master/random/un... (so it seems I don't like to specify the type of my functions...)
Explanation is here: http://chaoxuprime.com/2011/11/a-solution-to-Instagram-engin...