Well, I could go through all the pixels with a robot, but it should be faster than that. Much faster.
I am afraid that this is exactly what you will need to do.
If all the pixels should be white, you can first perform 30-pixel wide steps, and if you find a white pixel, take, say, 5 pixel steps, and then, if these pixels are also white, look at the remaining pixels in the square.
Something like that:
. . . . . . . .......... . . . ...... . . . . . . . . . . . .......... . .......... .......... .......... .......... . . . ..........
source share