Counting How Many Times a Point Passes Through a Grid of Coordinates

I ended up converting the following code from MATLAB to Julia and it works great:

I was having some problems with interpolation as the points are necessarily increasing in x dimension but this solution does the job and was quite easy to convert to Julia.