Fixed a bug in edge detection.