Create a MultiColor Image

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?".
Post Reply
lilith
Posts: 8
Joined: 2010-10-06T23:37:50-07:00
Authentication code: 8675308

Create a MultiColor Image

Post by lilith »

Hello,

I want to create a multicolored image as http://www.imagemagick.org/Usage/canvas ... lormap.jpg
I tried many commands, but not successfully :(
My goal is to have maximum of uniques colors in the smallest possible definition.

For example, i would have a 300x300 images with 90000 colors.
It's for a PNG filtering demonstration.

Thanks in advance !
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create a MultiColor Image

Post by fmw42 »

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Create a MultiColor Image

Post by anthony »

There are actually many ways to do this, some slow, some not so slow.
Most are listed in the Gradient Canvas area of IM examples, including the sparse color methods suggested.
http://www.imagemagick.org/Usage/canvas/#gradient

Another technique (very slow) is the use of FX to interpolate a small image, and is show in
http://www.imagemagick.org/Usage/misc/#interpolate

A variation on this (not shown on the page) is to use a two point affine distortion (distorting using the middle of pixels

Code: Select all

  convert \( xc:red xc:blue +append \) \
          \( xc:yellow xc:cyan +append \) -append \
          -filter point -interpolate bilinear -define distort:viewport=100x100 \
          -distort Affine '.5,.5 .5,.5   1.5,1.5 99.5,99.5'       interpolate_bilinear.jpg
Image

That is equivalent to the FX method and is faster but as you can see needs some setup.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
lilith
Posts: 8
Joined: 2010-10-06T23:37:50-07:00
Authentication code: 8675308

Re: Create a MultiColor Image

Post by lilith »

I've already tested that before posting. The proposed codes do not work for me, syntax seems to be incorrect. I'm running under Windows, with the lastest version.
Maybe i do not know how to use it. I'm a IM noob user, but if i copy your codes to a batch file, it just does not work.
For example :

Code: Select all

convert -size 30x600 xc:'#0F0' -colorspace HSB \
          gradient: -compose CopyRed -composite \
          -colorspace RGB -rotate 90  gradient_rainbow.jpg
To run that, I've to modify it to :

Code: Select all

convert -size 30x600 xc:#0F0 -colorspace HSB  gradient: -compose CopyRed -composite -colorspace RGB -rotate 90  gradient_rainbow.jpg
This is the only manipulation i've successfully done ! I tried to modify others, but it failed.
Thanks in advance.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Create a MultiColor Image

Post by anthony »

For conversion of UNIX type commands to DOS see...
http://www.imagemagick.org/Usage/windows/#dos
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create a MultiColor Image

Post by fmw42 »

See the link Anthony posted. But 3 issues are common

1) line continuations in Windows is ^ and not \
2) replace single quotes with double quotes
3) do not escape parens with \, no escape is needed
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Create a MultiColor Image

Post by anthony »

This discussion was continued but for a completely different topic or point.
All the posts involved has been split into a new topic in "Digital Image Processing"
with a topic name of "Resize using center of pixel (not edge)"
viewtopic.php?f=22&t=18846
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply