percol - Test if binary image is percolated
Function percol tests if an image is 4-connected from side to side. This is useful for analysing images comming from site percolation simulations. The percol routine has the advantage to be implemented in the C language.
p=0.02;
a = 1*(rand(10,10) <= p)
while (~percol(a)) // test the image if one side connects to the other
end
// now, surely, the image is connected side-to-side (i.e., it has percolated)
xbasc();
imshow(1-a,2); // 1 is displayed as black
http://siptoolbox.sourceforge.net