I am converting PNG icons to SVG, and results are better with sharp edges in the PNG. No gradients/anti-aliasing etc..
Results so far are ok, I am using a combination of -kmeans, -median, and -morphology arguments to ImageMagick to get the PNG into a nice state before vectorisation.
However, there are some pixels in the source image I am struggling to clean up, such as these slight gradients / antialiasing features of the image. I really need to despeckle/sharpen/remove any stray pixels as shown below.
Some ImageMagick options I've tried:
-kmeans 20 -median 5 -morphology CloseI Octagon:1
-statistic Mode 5 -median 7 -morphology Open Disk
-kuwahara 3 -median 4 -morphology Open Disk
-kmeans 20 -kuwahara 3 -median 4 -morphology open diamond:1 -unsharp 3
The ideal output (zoomed into that potion of the image) would just be 3 colors, something along these lines:
I'm struggling to find a combination of ImageMagick commands that don't result in messing up most of the image. I've tried googling for things like "ImageMagick despeckle" and "ImageMagick region flood fill" to try find a solution.
Here is a sample source image, and a sample output from ImageMagick:
Sample source image: https://i.stack.imgur.com/lcCco.png
Sample output image: https://i.stack.imgur.com/Duhl1.png
I have ImageMagick in my pipeline, but if there's a better tool or scripting language that produces better results in this area then I'm open to change.
Thanks for your ideas :)




