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?".

I am very new to imagemagick but I found it to be super helpful so thank you. I am running into an issue and I do not where I went wrong. I have checked the documentation, read thru countless forums. I may have read the answer without knowing that it applied to my question.

My objective is to change the color of a product and for this example, it is a shoe. I know that I have to first create the mask and I did this using the chroma key masking method as shown here http://www.imagemagick.org/Usage/photos. I had to change some of the fuzz values to get it pretty close.

I start with this first image
My actual code to create the mask looks like this:

it produces Which looks okay for my needs. During the time spent working on this, I was able to clear out more of the boxy shadow.

The issues I have are as follows

1. How can I change the color properly? at this time I have to mess with the modulation levels to get different colors and I do not think it is the correct way. I would like to be able to color the masked area to any CMYK, RGB or Hex Value so I am limited to guessing -modulate

2. Am I doing this the right way or am I taking a really long road instead of taking a shorter one? My goal is to be able to recolor products and have them look as real/natural as possible.

On the last bit of code above,

I have tried changing between convert to composite (following the syntax) with no luck
I have tried -colorspace RGB -fill rgb(x,x,x) with no luck
I have tried -background and it changes the entire image.

I have actually found and read replacecolor on your page, I forgot to mention it. That's what told me it had to be possible.

Unfortunately, I would not know how to run unix on my machine. I know there is cygwin out there but I have never used it and I am not familiar with anything *nix except for maybe lists and changing directories.

HCL and HSL can both give the same results, given suitable parameters to "-modulate". But HCL is easier to control. For example, shifting the hue from blue to yellow in HSL will visually lighten it, but in HCL the visual lightness stays roughly constant.

If you have a patch on the image of a certain colour, and you want to change it to another colour, you can have a script that:

1. scales both patches to one pixel each;
2. converts those to HCL
3. subtracts the first channel, the "red" channel.

I downloaded windows 10 unix bash shell. I got it up and running but I was not able to call the script and when I finally did I did not know what the error messages meant (I am not familiar with linux at all) it took me some time but I ended up downloading a virtualbox and installing Ubuntu.

I then read thru the documentation and installed the latest version of ImageMagick. I ran into a few problems with the delegates and installing them. This was my first interaction with any *nix system ever so I had no frame of reference. I tried a lot of suggestions but this is the one that worked https://askubuntu.com/questions/745660/ ... l-problems.

After that, I tested the replacecolor script and it worked! so thank you for that.

I also tried snibgo's suggestion and I messed with -set colorspace to HCL and then -modulate and I got some different results but I was/am still clueless as to how to apply a color and it is most likely due to not understanding certain fundamentals.

I appreciate both of your help and I will continue looking at the documentation.

-modulate shifts colors from their current values. It does not set colors to a specific value. You need to work in Hue space and convert your colors from one Hue value to another. That is basically what I do in my scripts. See my script, huemap, also. It works by hue values and their is a hue chart for reference. My script replacecolor converts the input and output colors to hue (and brightness and saturation) and replaces hues.