Greetings,
I read with interest about the new Voronoi' Morphology Distance method that "will fill in holes using the nearest non-transparent edge pixel".
Can someone please show me an example how to use this feature?
Thank you!
Voronoi' Morphology Distance method
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Voronoi' Morphology Distance method
see http://www.imagemagick.org/Usage/canvas/#sparse_fill
It -sparse-color just looks for fully transparent pixels and replaces them with one of the appropriate interpolation methods, shepars, voronoi, etc
you can just replace shepards with voronoi.
I use voronoi in my script, stainedglass, at the link below. So you can see from the script how I did that. It has been a while since I wrote that so I am a bit fuzzy on it, but it mostly follows Anthony's example above. I just created a repeated pattern of individual pixels sampled from the image onto a transparent image background and then used -sparse-color voronoi to fill in the transparent values.
It -sparse-color just looks for fully transparent pixels and replaces them with one of the appropriate interpolation methods, shepars, voronoi, etc
you can just replace shepards with voronoi.
I use voronoi in my script, stainedglass, at the link below. So you can see from the script how I did that. It has been a while since I wrote that so I am a bit fuzzy on it, but it mostly follows Anthony's example above. I just created a repeated pattern of individual pixels sampled from the image onto a transparent image background and then used -sparse-color voronoi to fill in the transparent values.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Voronoi' Morphology Distance method
As fred pointed out, Voroni is a sparse color method, and while related to a Morphology Distance Gradient, it is not the same.
It is also a 'point' solution where it looks for the nearest colored point that was given in a list. The provided image only provides a 'base canvas' on which it works, and which it will overwrite (unless a write or clipping mask was set).
You can however convert the edges of an image into a 'point list' for voronoi point filling!
See the 'shepards fill' example in...
http://www.imagemagick.org/Usage/canvas/#sparse_fill
The key is to only generate a list of edge pixels so that the 'point list' is kept to a minimum.
(This is something I would have liked to build into IM but never got around to it)
I did make a note morphology distance function (which their is half a dozen distance metric for) can be used to generate a 'fast voronoi' fill method. however this requires that while the distance function is generated in one channel (typically a negated alpha channel), the values in the other channels (color) of any newly discovered the 'nearest pixel' also need to be copied at the same time.
It is a tricky solution but works without needing a point list, and for any number of pixels, is just two passes through the image just as the distance function does, instead of the current one pass with a list. Also you can make selection
of different and simpler distance metrics (like a Knights Move, or Octagon) than just Eucliedien.
It is part of first stage in a true 'diffusion hole filling' technique, which understands boundary conditions, unlike a 'shepards fill' technique that is already available, and even provides a faster blurred image stack alternative.
It is a variation that requires some addition programming which I have not had the time to make.
I have however attempted tried to implement in other ways as quick experiments (in hole filling), quite some time ago, but nothing really useful came from it.
It is also a 'point' solution where it looks for the nearest colored point that was given in a list. The provided image only provides a 'base canvas' on which it works, and which it will overwrite (unless a write or clipping mask was set).
You can however convert the edges of an image into a 'point list' for voronoi point filling!
See the 'shepards fill' example in...
http://www.imagemagick.org/Usage/canvas/#sparse_fill
The key is to only generate a list of edge pixels so that the 'point list' is kept to a minimum.
(This is something I would have liked to build into IM but never got around to it)
I did make a note morphology distance function (which their is half a dozen distance metric for) can be used to generate a 'fast voronoi' fill method. however this requires that while the distance function is generated in one channel (typically a negated alpha channel), the values in the other channels (color) of any newly discovered the 'nearest pixel' also need to be copied at the same time.
It is a tricky solution but works without needing a point list, and for any number of pixels, is just two passes through the image just as the distance function does, instead of the current one pass with a list. Also you can make selection
of different and simpler distance metrics (like a Knights Move, or Octagon) than just Eucliedien.
It is part of first stage in a true 'diffusion hole filling' technique, which understands boundary conditions, unlike a 'shepards fill' technique that is already available, and even provides a faster blurred image stack alternative.
It is a variation that requires some addition programming which I have not had the time to make.
I have however attempted tried to implement in other ways as quick experiments (in hole filling), quite some time ago, but nothing really useful came from it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/