ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

opencv distance transform

asked 2011-12-16 12:12:44 -0500

Aditya gravatar image

updated 2011-12-16 12:14:02 -0500

I am not sure if this is the right place for an OpenCV question, but I will ask nonetheless :) I want to compute distance transform on a cv::Mat object. However, for each pixel in the matrix, along with its distance to the nearest zero pixel, I want to identify the nearest zero pixel (row/col) as well. Is there any in-built OpenCV functionality to achieve this? Thanks!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2011-12-17 03:40:12 -0500

I am not sure but I think that is called the "nearest feature transform" and AFAIK it is not implemented in OpenCV.

In any case you only want to find the nearest zero feature of a few of points you can find it integrating the trajectory which start in your "working point" following the gradient of the distance transform image. On a few steps bounded by the sqrt(width*height) you will find eventually the nearest zero feature.

edit flag offensive delete link more
0

answered 2011-12-16 20:53:32 -0500

noonv gravatar image

cv::distanceTransform() :)

edit flag offensive delete link more

Comments

I think my question was not clear, sorry about that. Using cv::distanceTransform, I get for each pixel the distance to the nearest zero pixel. However it does not identify the nearest zero pixel the distance is from. Is there any in built functionality to do that?
Aditya gravatar image Aditya  ( 2011-12-17 02:20:30 -0500 )edit
As far as I know - no
noonv gravatar image noonv  ( 2011-12-17 02:38:06 -0500 )edit

DIST_LABEL_PIXEL ought to identify the nearest pixel. http://docs.opencv.org/2.4/modules/im...

lucasw gravatar image lucasw  ( 2016-03-01 10:09:23 -0500 )edit

Question Tools

Stats

Asked: 2011-12-16 12:12:44 -0500

Seen: 1,595 times

Last updated: Apr 10 '12