How to Manipulate Patterns with Imagemagick Distort
-
- Posts: 11
- Joined: 2017-12-21T00:05:01-07:00
- Authentication code: 1152
How to Manipulate Patterns with Imagemagick Distort
hi!
i want to change Plaid Fashion Fabric pattern on clothes,like dress,t-shirt. looks like Really clothes.
i find ps method Illustrator Tutorial: How to Manipulate Patterns with Envelope Distort (http://fashionclassroom.com/blog/illust ... pe-distort)
and
i find Use The Displace Filter & Displacement Maps To Make It(http://www.photoshopsupport.com/element ... t-map.html)
but i want to command auto it.
so Imagemagick how to do this?
like this
this is model picture
this is fabric pattern
thinks ....
i want to change Plaid Fashion Fabric pattern on clothes,like dress,t-shirt. looks like Really clothes.
i find ps method Illustrator Tutorial: How to Manipulate Patterns with Envelope Distort (http://fashionclassroom.com/blog/illust ... pe-distort)
and
i find Use The Displace Filter & Displacement Maps To Make It(http://www.photoshopsupport.com/element ... t-map.html)
but i want to command auto it.
so Imagemagick how to do this?
like this
this is model picture
this is fabric pattern
thinks ....
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to Manipulate Patterns with Imagemagick Distort
See viewtopic.php?f=1&t=20455 and viewtopic.php?f=1&t=23348 and viewtopic.php?f=1&t=16921#p62696 and viewtopic.php?f=1&t=22890&start=15
But you need to have a mask image or transparency to separate the jacket from the white background.
But you need to have a mask image or transparency to separate the jacket from the white background.
-
- Posts: 11
- Joined: 2017-12-21T00:05:01-07:00
- Authentication code: 1152
Re: How to Manipulate Patterns with Imagemagick Distort
thank fmw42. i am trying . yes, i have the transparency psd file with model clothes. only question is auto command script apply it ....fmw42 wrote: ↑2017-12-21T00:27:15-07:00 See viewtopic.php?f=1&t=20455 and viewtopic.php?f=1&t=23348 and viewtopic.php?f=1&t=16921#p62696 and viewtopic.php?f=1&t=22890&start=15
But you need to have a mask image or transparency to separate the jacket from the white background.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to Manipulate Patterns with Imagemagick Distort
The basic idea is as follows (unix syntax)
1) extract or make a mask (here I make it from your image, since the coat image did not have transparent background)
2) convert the coat image to grayscale, apply the mask into the alpha channel and then get the average gray level of the opaque pixels
3) compute the amount needed to add or subtract so that the average grayscale is 50% and increased the contrast. This is needed for the hard light composite
4) shrink your texture image and tile it out to the size of the coat image
5) combine the modified grayscale coat image with the tiled texture image and mask using -compose hard light to bring out the detail from the coat image
1) extract or make a mask (here I make it from your image, since the coat image did not have transparent background)
2) convert the coat image to grayscale, apply the mask into the alpha channel and then get the average gray level of the opaque pixels
3) compute the amount needed to add or subtract so that the average grayscale is 50% and increased the contrast. This is needed for the hard light composite
4) shrink your texture image and tile it out to the size of the coat image
5) combine the modified grayscale coat image with the tiled texture image and mask using -compose hard light to bring out the detail from the coat image
Code: Select all
convert mens_hoodie_back.png -bordercolor white -border 1 \
-fuzz 0.2% -fill black -draw "color 0,0 floodfill" -alpha off \
-fill white +opaque black -blur 0x1 -level 50x100% -shave 1x1 tmp1.png
Code: Select all
color=`convert mens_hoodie_back.png -colorspace gray tmp1.png \
-alpha off -compose copy_opacity -composite -scale 1x1! \
-alpha off -type grayscale -format "%[pixel:u.p{0,0}]" info: | tr -cs "0-9*\n" " "`
diff=`convert xc: -format "%[fx:0.5-($color/255)]" info:`
echo "color=$color; diff=$diff"
color= 71 ; diff=0.221569
Code: Select all
convert mens_hoodie_back.png \( 0344796.jpg -resize 10% +write mpr:tile +delete \) \
-tile mpr:tile -draw "color 0,0 reset" tmp2.png
Code: Select all
convert tmp2.png \
\( mens_hoodie_back.png -colorspace gray -evaluate add $diff -sigmoidal-contrast 1x50% \) \
-compose hardlight -composite tmp1.png \
-compose over -alpha off -compose copy_opacity -composite \
result.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to Manipulate Patterns with Imagemagick Distort
Here is a better example that includes displacing the pattern.
1 ) flatten the hoodie image, since it has an alpha channel that defines the color not the mask
2 ) use flood fill to make a mask image separating the hoodie from the background area
3 ) put the mask into the alpha channel and get the average grayscale of the opaque region
4 ) get a difference value for making the lighting image and for the displacement image
5 ) resize the pattern and tile it out to the size of the hoodie image
6 ) apply the lighting difference to the clothing image to make the average grayscale at 40% (adjust as desired for brightness)
7 ) apply the displace difference to the clothing image to make the average grayscale at 50%, enhance the contrast and make the background area transparent 50% gray so that it does not get displaced in the background area
8 ) combine the tiled_pattern image with the lighting image using hard light composite then apply the displacement image to distort the pattern on the hoodie.
1 ) flatten the hoodie image, since it has an alpha channel that defines the color not the mask
2 ) use flood fill to make a mask image separating the hoodie from the background area
3 ) put the mask into the alpha channel and get the average grayscale of the opaque region
4 ) get a difference value for making the lighting image and for the displacement image
5 ) resize the pattern and tile it out to the size of the hoodie image
6 ) apply the lighting difference to the clothing image to make the average grayscale at 40% (adjust as desired for brightness)
7 ) apply the displace difference to the clothing image to make the average grayscale at 50%, enhance the contrast and make the background area transparent 50% gray so that it does not get displaced in the background area
8 ) combine the tiled_pattern image with the lighting image using hard light composite then apply the displacement image to distort the pattern on the hoodie.
Code: Select all
convert mens_hoodie_back.png -flatten -colorspace gray clothing.png
Code: Select all
convert clothing.png -bordercolor white -border 1 -fuzz 0.2% -fill black -draw "color 0,0 floodfill" \
-alpha off -fill white +opaque black -blur 0x1 -level 50x100% -shave 1x1 mask.png
Code: Select all
color=`convert clothing.png mask.png -alpha off -compose copy_opacity -composite \
-scale 1x1! -alpha off -type grayscale -format "%[pixel:u.p{0,0}]" info: | tr -cs "0-9*\n" " "`
diffl=`convert xc: -format "%[fx:(40-100*($color/255))]" info:`
diffd=`convert xc: -format "%[fx:(50-100*($color/255))]" info:`
echo "color=$color; diffl=$diffl; diffd=$diffd"
color= 227 ; diffl=-49.0196; diffd=-39.0196
Code: Select all
convert clothing.png \( 0344796.jpg -resize 10% +write mpr:tile +delete \) \
-tile mpr:tile -draw "color 0,0 reset" tiled_pattern.png
Code: Select all
convert clothing.png -evaluate add $diffl% lighting.png
Code: Select all
convert \( clothing.png -evaluate add $diffd% -sigmoidal-contrast 5x50% \) \
mask.png -alpha off -compose copy_opacity -composite \
-background "gray(50%)" -alpha background displace.png
Code: Select all
convert tiled_pattern.png lighting.png -compose hardlight -composite \
displace.png -define compose:args=5x5 -compose displace -composite new_result.png
Re: How to Manipulate Patterns with Imagemagick Distort
The second method is nicer fmw42 but I think the pattern is too bold and does not really show the full detail!
I would also think the band on the waist would not have the pattern; that area as well as the cuffs is usually elasticated. But that would be possible to do by the OP modifying the mask in those areas.
I would also think the band on the waist would not have the pattern; that area as well as the cuffs is usually elasticated. But that would be possible to do by the OP modifying the mask in those areas.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to Manipulate Patterns with Imagemagick Distort
I what way is it too bold. Can you give me more details. Is it too much distortion? Or too dark an image? What specifically?
That is correct. But it would require manual adjustment. Or better to have remade masks images for different parts of the clothing so that the texture pattern could be rotated suitably?
Re: How to Manipulate Patterns with Imagemagick Distort
Not a problem with your example but the pattern is so strong you can not see the wrinkles etc. in the final image very well. I know that is the pattern the OP wanted but a slightly lighter pattern will show off the wrinkles better?I what way is it too bold. Can you give me more details. Is it too much distortion? Or too dark an image? What specifically?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to Manipulate Patterns with Imagemagick Distort
Bonzo: Yes that is true. Changing the desired diffl value of 40 to a higher value would increase the brightness of the pattern but also the shadows. I originally had it at 50, but that did not look good. So I lowered it to 40 to keep the pattern image mostly the same brightness as it had.
-
- Posts: 11
- Joined: 2017-12-21T00:05:01-07:00
- Authentication code: 1152
Re: How to Manipulate Patterns with Imagemagick Distort
and
How do I cut the picture, then put on the clothes, sleeves, respectively, cloth, and then through the command combination back to a complete picture.
imagemagick command I'm not familiar yet
thanks...
How do I cut the picture, then put on the clothes, sleeves, respectively, cloth, and then through the command combination back to a complete picture.
imagemagick command I'm not familiar yet
thanks...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to Manipulate Patterns with Imagemagick Distort
You will need to make a mask of the t-shirt as a binary image. Then process as in the earlier example. Then use the mask to composite the new t-shirt onto the original image.
-
- Posts: 11
- Joined: 2017-12-21T00:05:01-07:00
- Authentication code: 1152
Re: How to Manipulate Patterns with Imagemagick Distort
thanks...i am trying....
-
- Posts: 11
- Joined: 2017-12-21T00:05:01-07:00
- Authentication code: 1152
Re: How to Manipulate Patterns with Imagemagick Distort
hi,thanks fmw42.
i process as in the earlier example.
1. this is origin image child.png
2. then Split to mook.png with PS
3. then extract mask.png with PS
4. then get tiled_pattern.png
5.then get lighting.png
6. then get displace.png
7.then composite new_result.png
8.last composite to origin temp_result.png
Feeling still some interference, the image is not clear enough, there are noise
Where is the problem?
If I want to adjust the pattern of stripes position and zoom how to use the command
so when i got child.png.
and in ps to process to mask.png lighting.pnd displace.png
and then command to scaling pattern image and the pattern image pos x and pos y.
will be better?
i process as in the earlier example.
1. this is origin image child.png
2. then Split to mook.png with PS
3. then extract mask.png with PS
4. then get tiled_pattern.png
5.then get lighting.png
6. then get displace.png
7.then composite new_result.png
8.last composite to origin temp_result.png
Feeling still some interference, the image is not clear enough, there are noise
Where is the problem?
If I want to adjust the pattern of stripes position and zoom how to use the command
so when i got child.png.
and in ps to process to mask.png lighting.pnd displace.png
and then command to scaling pattern image and the pattern image pos x and pos y.
will be better?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to Manipulate Patterns with Imagemagick Distort
Your lighting image is too bright and perhaps not enough contrast. It needs to be near 50% gray. Lower the value from 50% or 40%, whichever you used to avoid the washed out areas.
To change the pattern, you can adjust the resize factor. To shift the pattern, you can add -roll +X+Y after tiling it.
To change the pattern, you can adjust the resize factor. To shift the pattern, you can add -roll +X+Y after tiling it.
-
- Posts: 11
- Joined: 2017-12-21T00:05:01-07:00
- Authentication code: 1152
Re: How to Manipulate Patterns with Imagemagick Distort
thanks fmw42.... i have a other question.
Bending clothes arm, skirt skirt and so on. May be irregular graphics. How to better make random patterns to match naturally. Similar to dyed fabric.
i follow the viewtopic.php?f=1&t=23348 .
But other irregular images may not be symmetrical. I do not know what I described clearly.
Bending clothes arm, skirt skirt and so on. May be irregular graphics. How to better make random patterns to match naturally. Similar to dyed fabric.
i follow the viewtopic.php?f=1&t=23348 .
But other irregular images may not be symmetrical. I do not know what I described clearly.