I cant say that I understood all in here, but that won't stop me from
adding my "mustard"
I would create 2 arrays of "struct blob" (minx,maxx,miny,maxy), both
big enough to hold the maximum amount of blobs I expect per line
(+safety offcoure, lets say struct blob even[20] and odd[20]).
I would now start with line 0, and eachtime I get a hit I fill in
the mins into one odd blob.
I'll then search for the end of the blob in
this line and and add the maxx. Maxy is set to the same as miny.
Then I do the same for line 1 filling in odd blobs.
Now I do check wether blobs in even are connected to blobs in odd, and
change the odd ones to include the even one.
Even blobs that have no partner are fully found and pushed into the
outbuffer.
And now I fill the even blobs with line 2 and so one.
Makes sure at every pixel is only looked at once, and I don't think
the blob-comparing adds much overhead.