Smart Scanning Microscope Adapts to Sample Morphology