1 | initial version |
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). Hope it is clear enough.
2 | No.2 Revision |
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.