In my game, I want to place squares on the edges of a monochrome image: 
So, I found this algorithm that should solve the problem. http://en.wikipedia.org/wiki/Marching_squares
It seems like it's hard to implement, I just think I donβt understand what the Wiki is saying. I think I need to split the image into cells, where each cell displays 2x2 pixels in the image? It's right? Then I lose this instruction:
For each cell in the contour grid:
1.Perform 4 bits in the corners of the cell to build a binary index: clockwise the cell, add a bit to the index using bitwise OR and left shift, from the most significant bit in the upper left, to the least significant bit in the lower left corner. The resulting 4-bit index can have 16 possible values ββin the range 0-15.
I am not sure how to add a bit.
thanks
source share