Pixel "selection" algorithm
I am trying to write an algorithm that operates on a 2-bit (Black and white) image. Given a black pixel, it needs to be able to find all other black pixels that are directly connected to it, or indirectly connected to it (connected to it by being connected to another pixel that is directly connected to it, however many levels deep). (If you have ever used photoshop before, I am basically refering to the idea of a very simplified magic wand selection tool) I currently have this method implemented recursively, it traverses through the pixels as though they were a tree structure, which works for smaller images, but for larger images (longer paths to traverse) it gets a stack overflow. Does anyone know of any algorithms that would preform this kind of a task?

