Edge segment linking based on gray level and geometrical compatibilities