Here is a good starting place https://stackoverflow.com/questions/...use-in-c-sharp
Then do a line by line edge find and log the coordinates for each point. It has been a long time since I wrote the code to do something like this, so I forgot exactly how to do it. But I do remember converting the image to a grayscale bmp so I could read the raw image data pixel by pixel.
You have a lot of studying to do. Google will be your friend here.