Fast clustering for scalable statistical analysis on structured images