Contrast-detection autofocus