Find indices of nearest zero pixel after distance transform

asked 2018-09-14 07:59:29 -0600

eudoxos gravatar image

updated 2018-09-14 08:26:22 -0600

I have image I with holes (NaNs) and would like to use distance transform to fill those holes with the nearest valid value. The cv::distanceTransform function optionally return labels of nearest zero pixels; what I however need is to find, for each pixel, the i-j coordinate of the nearest zero pixel rather than its label. Is there some way to do that with distanceTransform?

In scipy.ndarray, this is what distance_transform_edt does with return_indices=True.

edit retag flag offensive close merge delete