Page 1 of 1
get color from image put on another image
Posted: 2012-02-24T21:51:33-07:00
by sujan.dasmahapatra
I am able to change the color of an image like this
Code: Select all
exec("convert shirt.jpg +level-colors black,blue shirtmod3.jpg");
[code]
so my shirt color is chaning from white to blue etc. any color.
Now I have a set of images all images representing a color, sometimes the colors are strips. How can I get that color and put it onto the shirt using +level-colors. I want to design my shirts with custom colors. Please give me some suggestions. Thanks a lot Sujan
Re: get color from image put on another image
Posted: 2012-02-24T22:13:29-07:00
by fmw42
Can you post an example of these color images. Are they a solid color?
The general idea is to get the average color of the image, save it to a string variable, then use that variable in +level-colors.
For unix/mac osx, one would do the following (but it will be different for Windows)
colorval=`convert colorimage -scale 1x1\! -format "%[pixel: u.p{0,0}]" info:`
This averages the image down to one pixel and so gives the average color if it is not perfectly uniform. However, if the color is perfectly uniform, then the -scale step can be ignored.
colorval=`convert colorimage -format "%[pixel: u.p{0,0}]" info:`
see
http://www.imagemagick.org/Usage/transform/#fx_escapes
now put that into your +level-colors
convert grayscaleimage +level-colors "black,$colorval" resultcolorized
Note the escape \ on the ! is to make sure you get only 1pixel.
The quotes on the "black,$colorval" are needed to allow the variable to be used and to ensure that you get the color result as either a name or an rgb(...) value.
If I misunderstand what you are trying to do, then please post an example of your color images and explain further.
Re: get color from image put on another image
Posted: 2012-02-24T23:29:26-07:00
by sujan.dasmahapatra
http://www.facebook.com/media/set/?set= ... 918&type=3
I have posted some pictures on my facebook shirts album. Please check I want those colors to put on my shirt images. I need to do it in windows. Please tell me how can get this colors and using +level-colors put then on shirts. Thanks a lot for your help.
Re: get color from image put on another image
Posted: 2012-02-24T23:42:30-07:00
by sujan.dasmahapatra
if you have a facebook account you can see this pictures my page. see the album shirts.
http://facebook.com/sujan.dasmahapatra
Re: get color from image put on another image
Posted: 2012-02-25T00:09:04-07:00
by sujan.dasmahapatra
Code: Select all
if(isset($_POST['fabric2_Sleeve_Style1']))
{
$colorval = exec("convert 3539.jpg -scale 1x1\! -format '%[pixel: u.p{0,0}]' info:");
exec("convert shirt.jpg +level-colors black,$colorval shirtmod1.jpg");
$imagepath = "shirtmod1.jpg";
echo "<img style='float:right;' src='$imagepath' />";
}
I am trying like this is this correct windows ?? Thanks
Re: get color from image put on another image
Posted: 2012-02-25T05:37:31-07:00
by sujan.dasmahapatra
i am trying to extract color like this and putting onto my shirt but it's not working can u help me.
Code: Select all
$ave=exec("convert 3539.jpg -filter box -resize 1x1! -format '%[pixel:u]' info:");
exec("convert shirt.jpg +level-colors black,$ave shirtmod1.jpg");
My shirt color is not coming as 3539.jpg...It's a navy blue color.
Re: get color from image put on another image
Posted: 2012-02-25T11:26:41-07:00
by fmw42
sorry I do not have a facebook account and do not intend to have one.
with regard to your post, I am not a windows user, so if you are running IM under windows on PHP I do not know how to answer that. You probably need to capture the text output and then convert it to a variable.
exec("convert 3539.jpg -filter box -resize 1x1! -format '%[pixel:u]' info: 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
then put the $out into a variable.
You could also try this, which may or may not work in PHP, but works in the terminal. But it is unix/mac syntax and won't work under windows.
convert shirtimage +level-colors black,$(convert colorimage -scale 1x1! -format "%[pixel: u.p{0,0}]" info:) tmp.png
Note on Unix you may have to escape the ! with \! (on windows it may be ^\ but I am not sure). Also on windows you need to escape % as %%.
Please clarify your environment (Unix, Mac OSX or Windows)
For such Windows/PHP things I will defer to Bonzo. See his web site at
http://www.rubblewebs.co.uk/index.php
Also see
http://www.imagemagick.org/Usage/windows/
Re: get color from image put on another image
Posted: 2012-02-25T12:03:57-07:00
by sujan.dasmahapatra
My conversion is now working fine. But when I am trying to get a color of strips then it's not working. If it's a single color I am able to capture it and put it onto shirt. like this
Code: Select all
$ave=exec("convert 3546.jpg -filter box -resize 1x1! -format '%[pixel:u]' info:");
exec("convert shirt.jpg +level-colors black,$ave shirtmod4.jpg");
where 3546.jpg is vaing a single color. But when my color is a strips color (like shirts with strips) then also it's showing a single color. strips image is not coming. Please tell me how can I capture that. Thanks a lot for your help.
Sujan
Re: get color from image put on another image
Posted: 2012-02-25T12:06:36-07:00
by fmw42
sujan.dasmahapatra wrote:My conversion is now working fine. But when I am trying to get a color of strips then it's not working. If it's a single color I am able to capture it and put it onto shirt. like this
Code: Select all
$ave=exec("convert 3546.jpg -filter box -resize 1x1! -format '%[pixel:u]' info:");
exec("convert shirt.jpg +level-colors black,$ave shirtmod4.jpg");
where 3546.jpg is vaing a single color. But when my color is a strips color (like shirts with strips) then also it's showing a single color. strips image is not coming. Please tell me how can I capture that. Thanks a lot for your help.
Sujan
-filter box -resize is going to be slower but produce the same result as -scale. I would suggest you use -scale 1x1!
Also [pixel:u] properly should be [pixel:u.p{0,0}] or [pixel:s.p{0,0}] see
http://www.imagemagick.org/Usage/transform/#fx_escapes
Without an image to look at for "strip color" I am not sure what you have or want from it. So please find some free web hosting site that has open access or just send me your example strip image to fmw at alink dot net
Are you trying to put multi-color pattern (
stripes) on your tshirt. For that you have to approach it totally differently. You must tile out your pattern and composite it with your shirt with a mask or transparency in your shirt image. For examples see
http://www.imagemagick.org/Usage/photos/#texture and
http://www.imagemagick.org/Usage/compose/#mask
Re: get color from image put on another image
Posted: 2012-02-25T21:32:47-07:00
by sujan.dasmahapatra
http://www.flickr.com/photos/75485396@N03/
check the above link. It's the strips color. I want this strips color should come on my shirt image. using
Code: Select all
$ave=exec("convert 15919.jpg -filter box -resize 1x1! -format '%[pixel:u]' info:");
exec("convert shirt.jpg +level-colors black,$ave shirtmod4.jpg");
single shade colors are coming fine. Please tell me how can i get the strips color. Thanks Sujan
Re: get color from image put on another image
Posted: 2012-02-26T04:03:05-07:00
by sujan.dasmahapatra
My image 15919.jpg is not just a color , but it's a pattern, how can i get that pattern and apply that on my shirt using +level-colors. Please help me.
Re: get color from image put on another image
Posted: 2012-02-26T12:13:52-07:00
by fmw42
sujan.dasmahapatra wrote:My image 15919.jpg is not just a color , but it's a pattern, how can i get that pattern and apply that on my shirt using +level-colors. Please help me.
You cannot use +level-colors. If your pattern is like the grid, then you have to make it tileable. Then tile it out to the same size as your shirt image. Make or use a mask for the shirt or transparency outside the shirt to composite the tiled pattern under the shirt image.
see the links above that I recommended. If you can provide your shirt image so we can experiment, then perhaps we can provide a command line for the above method.
Also see
http://www.imagemagick.org/Usage/canvas/#tile
http://www.imagemagick.org/Usage/compose/#tile
also IM has its own set of tileable patterns at
http://www.imagemagick.org/script/forma ... n-patterns
Re: get color from image put on another image
Posted: 2012-02-26T20:53:44-07:00
by sujan.dasmahapatra
now my pattern is coming on the shirt, but the looks is not acceptable is not realistic. How can I blend the pattern nicely with the shirt image. Please help me
below is the code snippet
Code: Select all
exec("convert 15919.jpg -normalize +level 35% texture.jpg");
exec("composite texture.jpg shirt.jpg -tile -compose Hardlight texture2.jpg");
exec("convert shirt.jpg -fuzz 50% -transparent white -alpha extract -negate mask.jpg");
exec("convert shirt.jpg texture2.jpg mask.jpg -composite shirtmod4.jpg");
$imagepath = "shirtmod4.jpg";
echo "<img style='float:right;' src='$imagepath' />";
I have posted shirt.jpg and shirtmod4.jpg and 15919.jpg at this location please have a look. Give me some suggestions for proper blending and realistic looks.
http://www.flickr.com/photos/75485396@N03/
Re: get color from image put on another image
Posted: 2012-02-26T21:42:55-07:00
by fmw42
What you have done is about all you can do with IM. You need a 3D model of the shirt and some texture mapping software. IM is more of a 2D system.
You have a similar but harder problem than in
viewtopic.php?f=2&t=20299
Sorry I do not know how to make IM do what you want.
Re: get color from image put on another image
Posted: 2012-02-27T11:37:36-07:00
by fmw42
The only other thing I can think of is to use displacement maps to modify your grid image according to the shading in the shirt.
see
http://www.imagemagick.org/Usage/mappin ... ement_maps
and
viewtopic.php?f=1&t=16921&p=62696&hilit ... irt#p62696