Your question fits into the realm of computer vision. This is a branch of computing where even many of the simple problems require a fair understanding of image processing and algorithms. I recommend you implement a CV library like AForget.NET to simplify the task.