Efficient and robust analysis-by-synthesis in vision