How can I get the source code of the Canny algorithm as used by MATLAB, it is fast and accurate. I want the source code because I want to implement it on hardware.

About the implementing it on hardware part, I would strongly advice you consult with a lawyer first. That being said, invoking

edit edge.m

from MATLAB gets you the source code.