The Canny algorithm is a more recent edge detector designed as a signal processing problem. In OpenCV, it outputs a binary image marking the detected edges.
Python:
import cv2
import sys
# Load the image file
image = cv2.imread('image.png')
# Check if image was loaded improperly and exit if so
if image is None:
sys.exit('Failed to load image')
# Detect edges in the image. The parameters control the thresholds
edges = cv2.Canny(image, 100, 2500, apertureSize=5)
# Display the output in a window
cv2.imshow('output', edges)
cv2.waitKey()