1. Inspection apparatus, comprising: an imaging module, which is configured to capture images of defects at different, respective locations on a sample; a memory, which is configured to store definitions of a plurality of defect classes in terms of respective classification rules in a multi-dimensional feature space; and a processor, which is coupled to the imaging module and the memory and is configured to process the images so as to automatically extract features of the defects from the images and to assign respective classifications to the defects by applying the classification rules to the extracted features, and to autonomously control the imaging module to continue capturing the images responsively to the assigned classifications.