2
$\begingroup$

I'd like to create some algorithm that can tell apart knots from links.

enter image description here

A knot is made up of one line, a link with multiple. As input, we expect images as above.

Is there an algorithm capable of classifying the images?

$\endgroup$
2
  • 1
    $\begingroup$ How many of these examples do you have? $\endgroup$
    – foreverska
    Commented May 3 at 15:42
  • $\begingroup$ assume as many as you need $\endgroup$ Commented May 3 at 15:47

1 Answer 1

2
$\begingroup$

This answer assumes that knots are one continuous path and links are multiple linked ;) paths.

The part that makes your examples tricky is that the images are 2D representations of a 3D thing, and "over/under" is implied by breaks in the path.

The computer vision algorithms that will help you are skeletonization, and analysis of skeletons. Here's a sketch of an algorithm. Steps 0 and 1 may or may not be necessary, and will depend on how variable your images are.

  1. Preprocess your image if necessary (threshold).
  2. Compute the skeleton of your image if necessary
  3. Find and label connected components of skeletons (image A below)
  4. Find tips of connected components (image B)
  5. Say two components are the same if there are tips close enough to each other.
  6. If there is one connected component, it's a knot, otherwise it's a link.

I ran this method on your image to produce images A and B. Here's a similar algorithm in python that looks to have similar functionality.

Step 2

enter image description here

Step 3

enter image description here

Step 4

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Huge thanks! What a great answer, insightful, informative. :) $\endgroup$ Commented May 9 at 16:09
  • $\begingroup$ Glad you found it helpful :D $\endgroup$
    – bogovicj
    Commented May 10 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .