Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Find indices of nearest zero pixel after distance transform

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?

Find indices of nearest zero pixel after distance transform

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=Trues.

Find indices of nearest zero pixel after distance transform

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=Truesreturn_indices=True.