Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You want to use the distanceTransform function. It gives you the distance to the closest 0 pixel, so you'll have to pre- and post-process the image.

Pre process by copying the image as a mask, and make everything not white equal to 1 or something. Then put a single black pixel around the edges.

Post-process by getting rid of the edge and taking everything not in the mask,setting it to whatever your no good value is. -1 you say.