Page 1 of 1

Help remapping colors

Posted: 2013-11-04T10:27:26-07:00
by mindv0rtex
Dear ImageMagick pundits. I am trying to remap the colors of this image
https://drive.google.com/file/d/0B6_zZu ... sp=sharing

Only the colors from this palette can be used
https://drive.google.com/file/d/0B6_zZu ... sp=sharing

For anyone interested, those are colors that one can purchase from the PixelHobby company to create a physical mosaic. I have tried using the free software that is available on their website for this purpose, but the results are poor because some colors (and hence details) are lost in the transition. Also, simply using the -remap operator produces poor results as well. Can anyone offer me a helping hand here if it is not too much trouble?

Re: Help remapping colors

Posted: 2013-11-04T10:51:04-07:00
by snibgo
This ...

Code: Select all

convert forest.gif -remap pixels.png r.png
... seems to work. What do you think is wrong? forest.png contains black pixels, but pixels.png doesn't have a black.

Re: Help remapping colors

Posted: 2013-11-04T10:56:46-07:00
by fmw42
I do not know that you can do better than with -remap in IM.

This is what I get with IM 6.8.7.4 Q16 Mac OSX

Code: Select all

convert forest.gif +dither -remap pixels.png forest_remap.gif
Image

Re: Help remapping colors

Posted: 2013-11-04T11:03:34-07:00
by mindv0rtex
What is unsatisfying for me in using the -remap is the details lost in the upper part and in the lower left corner because for both colors of the original image -remap picks the same closest alternative from the pixels.png. I thought maybe there is some clever way of changing the original image a little bit such that -remap would be able to preserve all the details...

Re: Help remapping colors

Posted: 2013-11-04T11:19:28-07:00
by magick
Add -gamma 1.6 to your command-line.

Re: Help remapping colors

Posted: 2013-11-04T11:50:10-07:00
by mindv0rtex
Gamma correction reveals the lost details but now -remap shifts blue colors to magenta...

Re: Help remapping colors

Posted: 2013-11-04T11:59:37-07:00
by snibgo
Another way is to note that the darkest colour in pixels.png is about 16%, so we reduce the contrast of the original by lightening it:

Code: Select all

%IM%convert ^
  forest.gif ^
  +level 16%%,100%% ^
  -remap pixels.png ^
  r.png

Re: Help remapping colors

Posted: 2013-11-04T12:17:12-07:00
by fmw42
mindv0rtex wrote:Gamma correction reveals the lost details but now -remap shifts blue colors to magenta...
Did you put -gamma right after reading the forest image? -gamma 1.6 may be too strong. try reducing it but keep it larger than 1.0

Perhaps a more linear adjustment such as user snibgo suggests may work better.