removed vigra UnionFind for thread safety
output is now cached