pixels adjacency

Two pixels are adjacent if they are neighbors and their intensity level satisfies some specific criteria of similarity.
Example (for binary images):
In binary images, 2 pixels are adjacent if they are neighbors & have some intensity value either 0 or 1. Here it doesn’t mean if a pixel is 0 its neighbor should have a binary value of 0 and vice versa for 1 to 1.

1,1 1,N
(Every box is a single pixel)

Suppose the above HTML structure is an image. and In the above image when we consider p(4,6) which is almost in middle and black. so this pixels adjacent is :
1. 3,5
2. 3,6
3. 3,7
4. 4,5
5. 4,7
6. 5,5
7. 5,6
8. 5,7
which is in 8 neighboring pixels. All marked in red