Morphological skeleton

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Morphological skeleton

Post by VanGog »

By chance I have found this article:

"Distance to Skeleton" and "Skeleton using Autotrace"
http://www.imagemagick.org/Usage/morpho ... e_skeleton

And I say, wow! That is exactly the same principle that I looked for few months ago. It is very similar to idea what I had before, when I thought about a way to compress image data. How one could generate little size image file (like greyscale PNG) to compress color PNG file. Example images:
http://www.icpdr.org/main/sites/default ... pe_map.png
Image

For case, that you have images like that, and there is quite many of the images and you wanna save file size. For example Imagine, you need to store data of rivers, but you have them in some format, that takes more space in the image because there are all the blue pixels.

My idea was to use the same method, as the "Distance to Skeleton" is, but to make it more sophisticated: to use "compression" - a possibility to generate the original image from the skeleton. My idea was not only to find the skeleton, but also keep information about original line width. That would be possible if the line would change from one color into shades of the color in which it is. Possibly - the more the original line was wide, the more the skeleton pixel would be darker. Some limitations are here sure, but this is that you can think about. The image would contain much less pixels (but more colors), because the skeleton saves the pixels. I believe it would be interesting way of storing data in that case that there are many or files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Morphological skeleton

Post by anthony »

You may like to pick apart the auto-trace program, as I am sure it generates skeletons for that exact reason.

Note the related morphology operator is a MAT which is a skeleton but with the value of the skeleton representing the radius of either a circle or square centred at the skeleton pixel. Basically a merger of the appropriate skeleton with the appropriate distance gradient. Note that such skeletons are typicall disjoint, and unlike 'thined' skeletons, are generally not 'connected'.

A MAT should be able to recreate an image, or the distance gradient, from just the skeleton pixel list. Of course this is assuming binary colors, but a image of few colors should work for this too.

I have not progressed quite that far when I was doing morphology implementation, but it should not be too far off.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: Morphological skeleton

Post by VanGog »

OK, I wrote email to autotrace, maybe they will be interested...

This is part of the email, here, because I added few new thoughts for the case, that in the image is some color (area) dominant:
What I would like to see is a function, that can convert such images to a format, that is similar to vector format, but the shapes of the file would use skeleton and color gradient to express distance of line from its shape. So the map or clipart would be reduced to a skeleton made from different colors. The idea is so simple. The more dark the color is, the longer the line is. The lighter the color is, the shorter the line is. So only you need to know is one point in the sceleton to create a line. The image should use a palette, e.g. with 16 or more colors.

First method would be needed to analyze what direction the lines should be drawn. If you have detailed image of river, you can find, that it is effective to save the lines in the direction where the river goes. But if you are in too much detail and the image (as detail of map) contains only blue color, then you could just have property in the image, which would say, draw the blue color on whole image.

You could also add a function, which inverts the sense of the method used. For example, if analysis would found that the image is mostly blue, so you will create property which says that the image is blue, but it contains some white lines, and you would need to record only the scelleton and gradient of the rest colors. You could go more far, if you would divided the image into quadrants...
Post Reply