Problem in 8 connectivity fixed:

In the previous algorithm, when on the side of an image, two rows looked like this in 8 connectivity, they would be classified as two objects:

Assume | shows the side of the image:

   .
   .
   | 1 0 ...
   | 0 1 ...
   .
   .

This was because I first checked the first row, then the first column and then went into the central parts of the image. To fix it, I only check the first column and then the first element of each row is checked while in the row. This will correct that problem.