Using canvas to detect graphs from a picture