Optimize performance and memory usage

At the mercy of the garbage collector, unfortunately. I think my use of
a set per pixel to determine which connected pixels are part of the same
set is hurting me, but the decision tree alternative is just so ugly to
stare at. Maybe if go had macros, or I was better at whipping up code
generators.