Page 1 of 1
convert white shade to red shade using recolor
Posted: 2012-02-18T22:55:28-07:00
by sujan.dasmahapatra
I want to convert the white shade of an image into red shade. I am trying using recolor but it's not coming. please help me
Code: Select all
convert shirt0.jpg -recolor '1 0 0 0 0 0 1 1 1' shirtmod01.jpg
Re: convert white shade to red shade using recolor
Posted: 2012-02-18T23:14:29-07:00
by fmw42
-recolor is now -color-matrix on more current versions of IM. -recolor has been deprecated and may or may not still work depending upon your version of IM. see
http://www.imagemagick.org/script/comma ... lor-matrix
But I don't think that -recolor (-color-matrix) is really what you want, because it is really a channel processing function and not pixel selective. Also as white contains equal red, green and blue, you will really turn everything red.
This only works for grayscale images:
convert image -color-matrix "1 1 1 0 0 0 0 0 0 " result
or
convert image -recolor "1 1 1 0 0 0 0 0 0 " result
You probably need to use the following on images of color including white so that you only change the white.
convert image -fuzz XX% -fill red -opaque white result
see
http://www.imagemagick.org/Usage/color_basics/#replace
and in particular
http://www.imagemagick.org/Usage/color_basics/#fuzz
Or see the following about changing shirt colors.
This one uses -modulate:
http://www.imagemagick.org/Usage/photos/#chroma_key
The other way, might be to create a mask as in the above and then convert your image to grayscale use -level-colors black,red. Then use the mask to composite the result from -level-colors with the original image.
see
http://www.imagemagick.org/Usage/color_ ... vel-colors
Or see my huemap script, below, though that does not work for white (or shades of gray)
Re: convert white shade to red shade using recolor
Posted: 2012-02-19T00:10:25-07:00
by sujan.dasmahapatra
i have tried using
convert image -fuzz XX% -fill red -opaque white result
This changing the color but exact shade is not coming. It looks like a color object, not looking like a shirt. i want the exact shade to come from the image but with a different color.
Re: convert white shade to red shade using recolor
Posted: 2012-02-19T00:26:46-07:00
by sujan.dasmahapatra
its not working... my shirt is white shade i want the exact shirt in red or green, or blue or any other custom color i want later.
using this my color is changing to skyblue with the exact shade of white
convert shirt.jpg -recolor '0 0 1 0 0 1 1 1 1' shirtmod3.jpg
But i am not able to get the same shade in red or yellow or some other color. Can u tell me what are these six parameters of recolor
-recolor '0 0 1 0 0 1 1 1 1' whats this numbers tells ? which one is the source and which one is the target.??
Re: convert white shade to red shade using recolor
Posted: 2012-02-19T01:49:45-07:00
by sujan.dasmahapatra
please tell me friend how can i use the functionality of recolor i am using imagick-6.6 i have the recolor feature in this version.
but i dont know how to make the color matrix. my source color is white, i want to convert all shades of white to red shade. how can i do that?
Re: convert white shade to red shade using recolor
Posted: 2012-02-19T11:55:46-07:00
by fmw42
Post a link to your input image and your blue output image. That way we can see exactly what you are trying to do.
But i am not able to get the same shade in red or yellow or some other color. Can u tell me what are these six parameters of recolor
-recolor '0 0 1 0 0 1 1 1 1' whats this numbers tells ? which one is the source and which one is the target.??
The rows are the source (input) and columns are the destination (output). If you want to learn how to use -recolor, see the interactive color matrix at
http://www.adobetutorialz.com/articles/ ... lor-Matrix
convert -size 100x100 gradient: -recolor '0 0 1 0 0 1 1 1 1' result.png
or in row, column format as
convert -size 100x100 gradient: -recolor \
'0 0 1 \
0 0 1 \
1 1 1' \
result.png
But the above shades
midtones only with
blue for me. It does not change pure white or pure black.
For red, do
convert -size 100x100 gradient: -recolor \
'1 1 1 \
0 0 1 \
0 0 1' \
result.png
For yellow do
convert -size 100x100 gradient: -recolor \
'1 1 1 \
1 1 1 \
0 0 1' \
result.png
However, there are easier ways.
Try this to change all shades of white, except black to blue:
convert -size 100x100 gradient: +level-colors 'black,blue' result.png
For this, just choose any color or shade you want in place of blue. See
http://www.imagemagick.org/script/color.php You can even specify colors as rgb(...) or hsl(...) or hex.
Alternately, if you want black converted to blue and pure white left alone, use
convert -size 100x100 gradient: +level-colors blue,white result.png
see
http://www.imagemagick.org/Usage/color_ ... vel-colors
Or to get something that does the same as your -recolor, that only changes midtones, but easier, use -tint
convert -size 100x100 gradient: -fill blue -tint 40% result.png
You can change the fill color. You can change the tint percent to make it lighter or darker (that is how much light and dark to color)
see
http://www.imagemagick.org/Usage/color_mods/#tinting
Re: convert white shade to red shade using recolor
Posted: 2012-02-24T04:12:13-07:00
by sujan.dasmahapatra
Thanks a lot friend. I am experimenting your last suggestions. thanks a lot.
Re: convert white shade to red shade using recolor
Posted: 2012-02-24T12:06:03-07:00
by sujan.dasmahapatra
my white color is not changing to red friend
I am doing like this
Code: Select all
<?php
if(isset($_POST['fabric2_Sleeve_Style1']))
{
exec("convert shirt.jpg -recolor '1 1 1 0 0 1 0 0 1' shirtmod1.jpg");
$imagepath = "shirtmod1.jpg";
echo "<img style='float:right;' src='$imagepath' />";
}
?>
my color is still white . not chaning to red. whats going wrong i wrote exactly u said above.
Re: convert white shade to red shade using recolor
Posted: 2012-02-24T12:21:56-07:00
by sujan.dasmahapatra
http://www.orkut.co.in/Main#AlbumZoom?g ... 0111104456 - this i s the shirt.jpg white shirt
http://www.orkut.co.in/Main#AlbumZoom?g ... 0111147518 - this is the skyblue shirt which i am able to make from white shirt using
Code: Select all
exec("convert shirt.jpg -recolor '0 0 1 0 0 1 1 1 1' shirtmod3.jpg");
Please tell me how can I change the white shirt to red and yellow and many more other colors which I need.
Re: convert white shade to red shade using recolor
Posted: 2012-02-24T16:44:04-07:00
by fmw42
First we cannot get to your files without a login. Second -recolor is too hard to work with to get a specific color and I suggest you try the other techniques that have already been mentioned, such as +level-colors or -tint.
Best I can come up with is the following:
1)Pick a color name or rgb value--say skyblue
2) Convert the rgb values to fractions between 0 and 1 (i.e. divide the rgb from 0 to 255 by 255 to get 0 to 1) see
http://www.imagemagick.org/contrib/color-converter.php r=135 -> 0.53, g=206 -> 0.81, b=235 -> 0.92
3) then use those values in the first two columns as follows
convert -size 100x100 gradient: -recolor \
"0.53 0.53 1 \
0.81 0.82 1 \
0.92 0.92 1" \
result_skyblue.png
but -tint and +level-colors are going to be much easier to use as they allow color names or rgb values or hex values
Re: convert white shade to red shade using recolor
Posted: 2012-02-24T20:22:22-07:00
by sujan.dasmahapatra
what does it mean by
convert -size 100x100 gradient: -recolor \
"0.53 0.53 1 \
0.81 0.82 1 \
0.92 0.92 1" \
result_skyblue.png
it should be convert source.png right. you have not mentioned source image.
I think it is
convert source.png -recolor \
"0.53 0.53 1 \
0.81 0.82 1 \
0.92 0.92 1" \
result_skyblue.png
Re: convert white shade to red shade using recolor
Posted: 2012-02-24T21:44:08-07:00
by fmw42
sujan.dasmahapatra wrote:what does it mean by
convert -size 100x100 gradient: -recolor \
"0.53 0.53 1 \
0.81 0.82 1 \
0.92 0.92 1" \
result_skyblue.png
it should be convert source.png right. you have not mentioned source image.
I think it is
convert source.png -recolor \
"0.53 0.53 1 \
0.81 0.82 1 \
0.92 0.92 1" \
result_skyblue.png
Yes, I used a gradient image just for testing to see how it shaded the image with the color,
because I could not download your images. You can replace it as follows:
convert source.png -recolor \
"0.53 0.53 1 \
0.81 0.82 1 \
0.92 0.92 1" \
source_skyblue.png
But it would really help to understand your image to see if there is a better way to achieve what you desire.
Re: convert white shade to red shade using recolor
Posted: 2012-02-24T21:48:15-07:00
by sujan.dasmahapatra
now my color shades are coming properly friend. I am following your suggestion for +level-color its coming perfect like this
exec("convert shirt.jpg +level-colors black,blue shirtmod3.jpg");
Thanks a lot.
Re: convert white shade to red shade using recolor
Posted: 2012-02-24T22:06:44-07:00
by fmw42
sujan.dasmahapatra wrote:now my color shades are coming properly friend. I am following your suggestion for +level-color its coming perfect like this
exec("convert shirt.jpg +level-colors black,blue shirtmod3.jpg");
Thanks a lot.
Yes, that is the syntax I had in mind to shade grays to white, but have black remain black. That is what we typically do for colorizing grayscale images as per Anthony's pages.