Ask Your Question
1

distance measurement

asked Jun 24 '13

sravanthi gravatar image

Hi,

I would like to find the distance between a colored dot to an edge in an image. How do I proceed with this?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Jun 24 '13

Guanta gravatar image

updated Jun 24 '13

Find the position of the colored dot in the image, e.g. by thresholding / template-matching. Having its x and y coordinate you can get the distances to the image edges easily: left_dist = x, right_dist = image.cols-1-x, upper_dist = y, lower_dist = image.rows-1-y. The Euclidian distance between two points 'pos' and 'other' in general is sqrt( (pos.x-other.x)^2, (pos.y-other.y)^2). So if you haven't meant image edge but an arbitrary edge in the image then you have to compute the edges first (e.g. by Canny()) and find it's nearest distance by comparing each distance of the point to the edge-points. Hope it is clear enough.

Preview: (hide)

Question Tools

Stats

Asked: Jun 24 '13

Seen: 613 times

Last updated: Jun 24 '13