Search code examples
pythoncomputer-visiongeometrycomputational-geometry

Is there a similarity measure to compare two segmented linear segments?


I am searching for a way to evaluate the similarity between two segmented linear segments. To make things clear, consider the illustration below:

enter image description here

Scanline 1 is very similar to the Template (in fact it's the Template segmentation pattern scaled down, so it has the same ratios between every segment pair as the Template).

On the other hand, Scanline 2 is way less similar to the Template.

The most relevant resource I found so far is the cross-ratio. However, using the cross-ratio metric as defined in the link above, we can only compare two linear segments that are segmented into 3 parts.

Any ideas of generalizing this metric or using another one as a metric?

Update: The metric should be scale invariant


Solution

  • Finally, the comparison of the scanlines will be done without thresholding the values of the image extracted one in order to avoid the "magic number" of the threshold. The comparison will be made between:

    • a binary template scanline derived from the 3d object's CAD model that shows where there is object and where there is not
    • a scanline derived from the image containing values in range [0, 255]

    The metric to be used is cross correlation implemented using convolution.