Pattern searching in material / shader


This might be a pretty n00b question, I’m coming from the programming side of things and starting to learn materials and shaders.

Lets say I have a texture with a pattern on it, a black and white voronoi pattern for this example. If I take in a point on that material, how can I flood out that section of the pattern and return a rough bounding shape, say a sphere or box?
So in this example, it would start on a white pixel, and move outwards until it hit a black pixel.


Any point in the right direction, would be great.