Converting an image into blocks of colour as a lego pattern

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
mrship
Posts: 5
Joined: 2011-02-18T07:54:39-07:00
Authentication code: 8675308

Re: Converting an image into blocks of colour as a lego patt

Post by mrship »

Thanks again for the tips. Here's where I've got to:

Original image:

Image


Processed image:
Image

This was using a combination thus:

Code: Select all

convert -colors 25 -treedepth 8
convert +dither -remap // with a palette derived from lego colours
convert -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle // is there a better way to achieve this?
convert -sample 512
convert -sample 256
convert -despeckle -despeckle -despeckle
./scripts/stainedglass.sh -k square -s 2 -t 0 // Fred's script
convert -sample 620
That gets pretty good results, which gives me a better place to start creating the manual grids, but it still isn't 100%. In particular, the black stripes of the tiger's face would have to be manually edited to remove the anti-aliasing that still in there.

I don't really know if I can move this further forward, but I'll see where else I can take it.

Thanks for all the help so far.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Converting an image into blocks of colour as a lego patt

Post by anthony »

Instead of despeckle, you could try the morphology 'intensity' functions with say a 'Square:3' kernel.
http://www.imagemagick.org/Usage/morphology/#intensity

The intensity versions do NOT create new colors. It compares using intensity and then uses that to select the while pixel color to be used as a result.

For example... This is a smooth by intensity variant.

convert rose: -morphology CloseI Square:3 -morphology OpenI Square:3 show:

Play with them :-)

I have not added a SmoothI or SmoothIntensity variant, but that could easily be added.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply