Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strange behavior with character graphs #12

Open
rfeinman opened this issue Oct 25, 2020 · 9 comments
Open

strange behavior with character graphs #12

rfeinman opened this issue Oct 25, 2020 · 9 comments

Comments

@rfeinman
Copy link

Hi, thank you for sharing this great python code.

I am trying to compute skeleton networks for images of handwritten characters (Omniglot dataset) and I've experienced strange behavior with some images. See figure below for a few examples. It seems that the network misses important edges in some cases; e.g. for the first character (column 1), the network misses the top-right curve completely. Do you know why this might be happening?

skeleton_graphs_omniglot

@yxdragon
Copy link
Member

hi, see the multi graph parameter!

@yxdragon
Copy link
Member

a tips:
a small hole [column 1] and little touch [columns 2] may lead small ring in the graph.
you can use skimage's remove_small_objects and binary_erode befor skeleton.

@rfeinman
Copy link
Author

Ah yes, multigraph is exactly what I needed. Thank you!

I was already using morphology.remove_small_holes, but now I see that morphology.binary_erosion is also useful for some cases, such as column 2. Thanks for the tip.

@rfeinman
Copy link
Author

One more question/request: is there an easy way to add the "maximum circle criterion" (Liao & Huang, 1990) for removing spurious branches and duplicate fork points? See image below for example. The algorithm places the largest possible circle on each critical point, such that the circle resides within the original ink (gray regions in d).

C.-W. Liao, J. S. Huang, Stroke segmentation by bernstein-bezier curve fitting. Pattern Recognit. 23, 475–484 (1990).

maximum_circle_criterion

@yxdragon
Copy link
Member

yxdragon commented Nov 8, 2020

Sorry for not review this issues for a long time. I think it is not difficult.

  1. iter every edge and mark the edges whitch not reach the limit.
  2. merge the node connected by marked edge to one

if it is useful for you, we can add another file to sknw, which do some graph repair. such as:

  1. remove the isolate node
  2. remove short branch
  3. remove the node whitch has just 2 edge (and combine the two edge to one)
  4. merge small circle as one node
  5. merge the node nearby to one
    ...

@yxdragon
Copy link
Member

yxdragon commented Nov 8, 2020

In my another repo, ImagePy (a ui framework for image processing)
here integrate some sknw's function, there are "remove isolate node", "remove 2 edges' node", "cut branch"
a topic on image.sc, here is some demo.

@rfeinman
Copy link
Author

Hi - Thank you so much for getting back to me about this! Sorry it has taken me a while to reply.

I looked at your demo and its great. I don't think I want to remove 2-edge or isolate nodes for my application. Some isolate nodes in characters are important, like dots. And corners are instances of 2-edge nodes, which I'd like to keep.

The new algorithm that you suggested sounds simple and effective. If you have a working implementation, I'd love to take a look. Otherwise I will work on crafting my own version.

@yxdragon
Copy link
Member

could you share a character image with many kinds of defect?

@rfeinman
Copy link
Author

Here are two demonstrative examples of the issue. I am showing the image and the current skeleton network. The L-shaped character should probably only have 1 node in the corner (rather than two). The w-shaped character should have 4 nodes total, not 6.

char_img
char_img_sknw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants