Hi, I would love to ask a question about the DistanceTransform algorithm.

I understand you need neighbor pixel’s distance to get your smallest distance, but why we must calculate it on the entire Matrix?

Let’s say I want to calculate distance transform on a thin contour, which takes place on a large bounding rectangle, couldn’t we calculate only the inside of the contour, instead of the entire matrix?

Is the current implementation of the DistanceTransform differs much to allow us to select specific pixels to calculate distance transform on? or when we get an entire contour, to at least assume the edge’s distances (either 1’s or 1.41’s), and keep calculating the inside of the contour?

I thank you for your time, and tysm, from yours truely,

OpenCV newb.