Adjacent pixels
(Note: the neighborhood area is indicated by yellow)
The 4-neighborhood of p, namely N4(p):
If the pixel values of q and p are both elements of the set V, and q is in the yellow area, then p and q are said to be adjacent to each other.
The 8-neighborhood of p, namely N8(p):
If the pixel values of q and p are both elements of the set V, and q is in the yellow area, then p and q are said to be adjacent to each other.
According to this definition, if p and q are 4 adjacent, then they must be 8 adjacent.
There is another neighborhood to pay attention to, namely ND(p):
First of all, we must explain an important point: 4-adjacent and 8-adjacent, there is no boundary between them and m connection, they are not independent relationships! While the two pixels are adjacent to each other by m, they can also be adjacent to 4 or 8!