Path between pixels

5 Ansichten (letzte 30 Tage)
med-sweng
med-sweng am 17 Feb. 2011
In the "Fundamentals of Digital Image Processing" by Annadurai book, it mentions the following:
A path between two pixels p and q with coordinates (x0,y0) and (xn, yn), respectively, is a sequence of pixels with coordinates (x0,y0), (x1,y1), (x2,y2),...(xn,yn), where (xi,yi) is adjacent to (xi+1,yi+1) for 1<=i<=n.
Can you just explain this paragraph? And, I think an example will pretty much help.
Thanks.

Antworten (1)

David Young
David Young am 17 Feb. 2011
The general statement can be expanded to a series of statements:
(x0, y0) is adjacent to (x1, y1)
(x1, y1) is adjacent to (x2, y2)
(x2, y2) is adjacent to (x3, y3)
(x3, y3) is adjacent to (x4, y4)
...
(xn-2, yn-2) is adjacent to (xn-1, yn-1)
(xn-1, yn-1) is adjacent to (xn, yn)
(In the arithmetic at the end, the -1 etc. is meant to apply to the subscript on x or y, not the value of x or y itself. So if n is 100, say, this means that (x99, y99) is adjacent to (x100, y100).
"Adjacent to" might mean various things, but this term is probably defined somewhere nearby in the book. Typically, it might mean that the two pixels are touching either along a side or at a corner (this is called 8-connectivity). Under this definition, the pixels with the following coordinates are adjacent to that at (x,y):
(x-1,y-1), (x,y-1), (x+1,y-1),
(x-1,y), (x+1,y),
(x-1,y+1), (x,y+1), (x+1,y+1)
(Now the arithmetic applies to the actual coordinates, not the subscripts.) A common alternative to 8-connectivity is 4-connectivity, where only the four pixels joining along a side count as "adjacent".
What this means graphically is easy to say. Draw a grid of pixels on a sheet of paper. Put your pen on pixel p. Move it to pixel q in steps, at each step going to a pixel that is adjacent to the current pixel. The sequence of pixels your pen passes through is a path between p and q.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by