Robust algorithm for detection of image features