Page 1 of 1

convert multiple color image into one color

Posted: 2010-12-14T04:07:52-07:00
by ratneshsoni
i want to know that is possible in image magick that convert all image color into one color. Like in one image there is 4 different colors and i want to replace these 4colors in one color like in black.
if it could be possible than how..reply soon

Re: convert multiple color image into one color

Posted: 2010-12-14T11:49:22-07:00
by fmw42
can you provide a link to an example of the image you want to change.

Does your image have only those four colors and no others? In IM, you can convert an image to one single color using -colorize. But I don't think that is really what you want to do.

In IM, you can make a series of calls to change any color to any other color. For example,

convert image -fuzz XX% -fill black -opaque red -fuzz YY% -fill black -opaque blue ... -fuzz ZZ% -full black -opaque green resultimage

The -fuzz XX% allows you to match the color within some XX% percent in case the color is not a pure color. You can define colors as names, rgb values and several other ways. The fuzz value can be different for each color or set to some fixed value once at the beginning or set to 0 to only match to exact colors.

For beginners, good reading is at

http://www.imagemagick.org/Usage/
http://www.imagemagick.org/script/comma ... ptions.php
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/script/color.php

Re: convert multiple color image into one color

Posted: 2010-12-14T23:11:16-07:00
by ratneshsoni
in my case there is no fix image that have many colors it will more than 4 colors or less than 4 colors but i want to change all these into one color. Like there is flag of America i want to change the color of that flag into one color.

Re: convert multiple color image into one color

Posted: 2010-12-15T11:00:18-07:00
by fmw42
try

convert image -fill desiredcolor -colorize 100% resultimage

That will convert the image so that it is filled completely with your desired color

Re: convert multiple color image into one color

Posted: 2010-12-15T23:32:46-07:00
by anthony
If sounds like you just want to blank the image to a single color canvas!
IM examples, Blanking Existing Images
http://www.imagemagick.org/Usage/canvas/#blank

If however you want it to become a gradient of color from say black-color-white. then you are
wanting to convert the image to greyscale, and tint the mid-tones...
http://www.imagemagick.org/Usage/color_mods/#tint

Or do you want something else?

Re: convert multiple color image into one color

Posted: 2010-12-15T23:47:16-07:00
by ratneshsoni
The above reply is coloring the image but the sharpness is missing. The sharpness which i seen in the site which i want i.e. in http://www.customink.com/lab/?PK=04600.
Please see this site as reference and tell me how to like this.
plz.plz.

Re: convert multiple color image into one color

Posted: 2010-12-16T10:40:18-07:00
by fmw42
ratneshsoni wrote:The above reply is coloring the image but the sharpness is missing. The sharpness which i seen in the site which i want i.e. in http://www.customink.com/lab/?PK=04600.
Please see this site as reference and tell me how to like this.
plz.plz.
Why don't you make examples from that site, save them to some free picture hosting site, then link the pictures here. We are all having trouble understanding what you want. Pictures would help tremendously.

When I go that site all I see is a white T shirt. That does not help. I don't know what you want to do there. Also their choice of colors may not be the same ones as in IM. See IM color names and color definitions as rgb or cmyk or hsl, etc at http://www.imagemagick.org/script/color.php

Are you trying to change the color of some T shirt on a model as in this site. If so, then you have to mask out the T shirt from the background image, so that you can change only the T shirt. Alternately, if the T shirt is white and there is no white anywhere else, you can use

convert image -fuzz XX% -fill some color -opaque white resultimage

Re: convert multiple color image into one color

Posted: 2010-12-16T17:08:28-07:00
by anthony
Perhaps if you tell us what you want to achieve, rather than what you think you want.

Re: convert multiple color image into one color

Posted: 2011-01-10T15:58:42-07:00
by grimholtz
Hi,

Found this thread while searching. I want to do the same thing. Here's an example:
http://img193.imageshack.us/img193/8233/gomezl.gif
Ignore the fact that the example is an animated gif. My images are not animated gifs.
You can see there are only two colors used: white and #6C6D70. The originals contains many more colors.

Any tips? Grayscale just doesn't cut it.

Thanks,
grimholtz

Re: convert multiple color image into one color

Posted: 2011-01-10T16:13:42-07:00
by anthony
Okay. You are NOT wanting two colors you are wanting a gradient between two colors.

First convert your image to greyscale, and normalize
http://www.imagemagick.org/Usage/color_mods/#grayscale
http://www.imagemagick.org/Usage/color_mods/#normalize

Then use +level-colors to set the gradient of colors you want to linearly map the gray scale to.
http://www.imagemagick.org/Usage/color_ ... vel-colors

There are many techniques for recoloring images and that section of IM examples "Color Modifications" covers the bulk of them.

Re: convert multiple color image into one color

Posted: 2011-01-10T16:19:16-07:00
by grimholtz
Really? That's a gradient? As far as I can tell (using Nattyware's pixie), it's a single color.

Re: convert multiple color image into one color

Posted: 2011-01-10T16:25:08-07:00
by fmw42
I downloaded your image from http://img193.imageshack.us/img193/8233/gomezl.gif and looked at the verbose info. Each frame is 8-bits with 64 colors (shades of gray).

But you have not really told us what you want to do. You should provide a link to the input image and and corresponding output image or explain better what you want to do.

Re: convert multiple color image into one color

Posted: 2011-01-10T16:32:33-07:00
by grimholtz
There are a variety of input images. They are all corporate logos. Here are a few:
http://img502.imageshack.us/img502/6905/nbalogo.png
http://img232.imageshack.us/img232/3448/pumalogo.gif
http://img59.imageshack.us/img59/7703/o ... ypress.jpg
etc.
They all have different color schemes. So in order to make them fit on my site, which uses yet another color palette, I want to make them gray-ish.

You asked for an output image. I don't have that yet. That's what I'm hoping imagemagick can help me with :) The best sample I can provide is this:
http://img193.imageshack.us/img193/8233/gomezl.gif

Anyway, I hope this explains what I'm trying to do. Imagine collating dozens of logos (all with different palettes) onto a single webpage. How would you make them look "matched"? Go with a single color or a gradient of a single color? I'm looking for opinions :)

thank you,
grimholtz

Re: convert multiple color image into one color

Posted: 2011-01-10T16:45:33-07:00
by fmw42
You have a mix of b/w (not sure about any anti-aliasing) and several (two?) color logos. The most reasonable thing would be to convert to grayscale, use -autolevel to stretch to full dynamic range and then possibly reduce the number of gray values using -color or set some color (grayscale) gradient using +level-colors firstgray,secondgray or just reduce the dynamic range using +level. With your binary images, you may want to convert them directly to some other shade of gray, perhaps midway between the two grays from +level-colors. If you have more than two colors in the logos or say some finite max number of colors, then you can map them to whatever values you want, one by one. Or you can set up a palette image of the grays you want and use -map (-remap).

There are really a lot of options and one would have to experiment with a good set of logos to figure out what might work for you.

see

http://www.imagemagick.org/Usage/color_mods/
http://www.imagemagick.org/Usage/quantize/#map

Re: convert multiple color image into one color

Posted: 2011-01-11T18:02:11-07:00
by anthony
grimholtz wrote:Really? That's a gradient? As far as I can tell (using Nattyware's pixie), it's a single color.
The bulk of the image is two colors, but the edge pixels use a gradient of colors to generate a smooth 'anti-aliased' edge, rather than a horrible looking 'aliased' staircase pixel effect.

Magnify the the edge of a logo using -scale and you will see the effect.
Examples of anti-aliasing are shown in IM Examples
http://www.imagemagick.org/Usage/antialiasing/

ASIDE: that is a very very old section that has seen no real work for years! Should do somethign about that, But I have a City in flood at the moment to worry about!