Go through the image pixel by pixel and check the color of each one. If the pixel is red, add the point (x/y coordinates) to a list of points that make up the road.
I'm not sure what you mean by function. Do you want a polynomial or a function to determine whether a particular point is on the road or not? If the former, look for a math library that has a curve fitting function that will take a set of points and give you back the polynomial that best fits those points. I suspect, though, that you probably want the latter. In that case, just have the function take the coordinates in question and search through your point set to determine if the point is in the set. This would fastest if you used a map/hash that encoded the coordinates into a key that you could look up using a O(1) operation.