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:
Code: Select all
magick convert shoe.jpg -modulate 100,100,20 -colorspace HSL ^
-channel Hue,Saturation -separate +channel ^
( -clone 0 -background none -fuzz 30%% +transparent grey64 ) ^
( -clone 1 -background none -fuzz 0.5%% -transparent white ) ^
-delete 0,1 -alpha extract -compose multiply -composite ^
shoe_mask1.png
I then follow the same guidelines in the chroma key and smooth out the mask.
The code is (with some minor changes from the guide)
Code: Select all
magick convert shoe_mask1.png -morphology Thicken ConvexHull shoe_write_mask.png
Still following the chroma-mask guide I then change the color.
The code is
Code: Select all
magick convert shoe.jpg -mask shoe_write_mask.png -modulate 150,100,170 +mask shoe-2.jpg
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 am using Windows 10 and mostly command line. IM Version 7.0.7-0 Q16 x64
Any help would be really appreciated.