The Algorithm
For every pixel in the image do the following:
If all the following conditions are true
2 <= B(p1) <= 6
A(p1) = 1
p2.p4.p8 = 0 or A(p2)!= 1
p2.p4.p6 = 0 or A(p4)!= 1
Change the pixel from black to white
Repeat this process until no changes are done.
Explaining the Conditions
Condition1: 2<=B(p1)<=6)
B(p1)<= 6 ------> p1 in B(p)
B(p1) > 6