I think there's a bug in there that flipped a few columns - but I actually really like the output better that way: http://imgur.com/RErXOF6
I do know that euclidean distance in RGB space is not that great a metric for perceptual similarity. Perhaps everything should be done in YUV instead? I will try tonight. Thanks.