Mathematical expression for connected multiple line segments

238 Views Asked by At

How can I write a mathematics equation for multiple line segments formed on an image pixel grid? Below is an example containing two lines. An object moves from (1,2) to (10,5) at time, t=1, then to (19,2) at t=2. Can we express the path of the object by a binary image?

enter image description here

1

There are 1 best solutions below

1
On BEST ANSWER

It sounds as if you're asking "How can I find the points through which the line passes during each straight-line path?" This is called "rasterization", and has been extremely well studied in computer graphics. The most computationally simple algorithm is probably Bresenham's, although the "midpoint algorithm" is pretty good as well. (You'll also find answers under the narrower topic of "scan conversion", which is a particular kind of rasterization, but often gets used as a synonym.)

If an algorithm like this is not what you're after, perhaps you can give a hint about what exactly would be better.