apply curv to image

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?".
vinod
Posts: 20
Joined: 2016-03-10T13:50:05-07:00
Authentication code: 1151

apply curv to image

Post by vinod »

hi i have vertical line image / fabric image , i want to apply that image on sleeve , but it appear straight whereas it would have curvy so how to apply curv to that image ? any idea ?

My line image / fabric
Image

sleeve image

Image

Expected

Image

Kindly Help me coz i am very near to result. .
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: apply curv to image

Post by Bonzo »

There are posts about this exact same question on the forum and I would try a search.

EDIT: This is probably the post you need: viewtopic.php?f=1&t=23348&hilit=shirt
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: apply curv to image

Post by fmw42 »

Where is your code? How can we advise without seeing that. Also always provide your IM version and platform, since syntax differs.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: apply curv to image

Post by fmw42 »

You have two issues that I see in your command and data from your PM to me:

1) your sleeve needs an adjustment in brightness and contrast
2) your stripe pattern is too coarse (stripes too far apart)

You can fix the second by appending the image to itself in both directions and scaling down the original size.

This is unix code.

Code: Select all

convert \( sleeve.png -brightness-contrast -10,20 \) \
\( line1.jpg +duplicate -append +duplicate +append -scale 50% \) \
\( -clone 0 \) \
\( -clone 1 -clone 0 -virtual-pixel transparent \
-compose displace -set option:compose:args -15x-15 -composite \) \
-delete 0,1 -compose multiply -composite line1_sleeve_result.png
Image

I believe the following is Windows syntax.

Code: Select all

convert ( sleeve.png -brightness-contrast -10,20 ) ^
( line1.jpg +duplicate -append +duplicate +append -scale 50% ) ^
( -clone 0 ) ^
( -clone 1 -clone 0 -virtual-pixel transparent ^
-compose displace -set option:compose:args -15x-15 -composite ) ^
-delete 0,1 -compose multiply -composite line1_sleeve_result.png
NOTE: you will get a slightly different pattern using 15x15 than with -15x-15 and the same as the former using 15x1.

You cannot bend the pattern on the sleeve unless you add other distortion images to cause the bend. See viewtopic.php?f=1&t=23348&hilit=shirt#p98071 and further down about bending.
vinod
Posts: 20
Joined: 2016-03-10T13:50:05-07:00
Authentication code: 1151

Re: apply curv to image

Post by vinod »

Thanks for your replay sir,

by applying this command
$cmd1 = "convert $source_image ( -clone 0 -auto-level -alpha off $fabric_image -virtual-pixel transparent -compose multiply -composite ) -compose SrcIn -composite $dest_image";

and over lap mask images on each other...

i am getting result as
Image

&


by applying this command
$cmd1 = "convert ( $source_image -brightness-contrast -10,20 ) ( $fabric_image +duplicate -append +duplicate +append -scale 50% ) ( -clone 0 ) ( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args 15x15 -composite ) -delete 0,1 -compose multiply -composite $dest_image";


and over lap mask images on each other...

i am getting result as
Image

in the last one -scale 50% makes some good result but it reflects
1) white border around images as you can see
2) depth is missed which comes by -auto-level

so what changes need to do in following command so i will not get much dark image by -auto-level and white borders will not come

$cmd1 = "convert ( $source_image -brightness-contrast -10,20 ) ( $fabric_image +duplicate -append +duplicate +append -scale 50% ) ( -clone 0 ) ( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args 15x15 -composite ) -delete 0,1 -compose multiply -composite $dest_image";

Thanks.

Kindly replay.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: apply curv to image

Post by fmw42 »

Sorry we do not understand what you are trying to do. Please post your input images along with the output.
vinod
Posts: 20
Joined: 2016-03-10T13:50:05-07:00
Authentication code: 1151

Re: apply curv to image

Post by vinod »

sir,

near about my issue is getting solved i got scaled pattern image from normal pattern image by this your command

convert brown_checks.jpg +duplicate -append +duplicate +append -scale 50% brown_checks2.jpg



normal pattern image Image

my scale image Image

thanks for this...

only in above command i want to add "displace -set option:compose:args 15x15"

how to set the command for this ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: apply curv to image

Post by fmw42 »

You have not posted all your input images. Please show us all your images, so we can test what you are doing. Also post your exact command lines.

see viewtopic.php?f=1&t=9620
vinod
Posts: 20
Joined: 2016-03-10T13:50:05-07:00
Authentication code: 1151

Re: apply curv to image

Post by vinod »

sir this is my input images

2.png Image

3.png Image

4.png Image

brown_checks.jpg Image

by this command

convert brown_checks.jpg +duplicate -append +duplicate +append -scale 50% brown_checks2.jpg

i got -scale image

brown_checks2.jpg Image

so that image i will apply on 2.png,3.png,4.png by this command

convert 2.png ( -clone 0 -auto-level -alpha off brown_checks2.jpg -virtual-pixel transparent -compose multiply -composite ) -compose SrcIn -composite 2_temp.png


convert 3.png ( -clone 0 -auto-level -alpha off brown_checks2.jpg -virtual-pixel transparent -compose multiply -composite ) -compose SrcIn -composite 3_temp.png


convert 4.png ( -clone 0 -auto-level -alpha off brown_checks2.jpg -virtual-pixel transparent -compose multiply -composite ) -compose SrcIn -composite 4_temp.png

thanks for this...

now only in

"convert brown_checks.jpg +duplicate -append +duplicate +append -scale 50% brown_checks2.jpg" this command i want to add
"displace -set option:compose:args 15x15"

how to set the command for this ? / how to add this in "convert brown_checks.jpg +duplicate -append +duplicate +append -scale 50% brown_checks2.jpg" this command ?

please replay. .
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: apply curv to image

Post by fmw42 »

Your white lines in the middle come from your input images. If you composite them together, you will see the lines.

Code: Select all

convert 2.png 3.png 4.png -background none -flatten 234.png
Image

However, in your code you use -auto-level on each one separately.

We can do something similar as

Code: Select all

convert 2.png 3.png 4.png -auto-level -background none -flatten 234b.png
Image

If we do your processing separately on each image as follows, we get

Code: Select all

convert 2.png -auto-level \
\( brown_checks.jpg +duplicate -append +duplicate +append -scale 50% \) \
\( -clone 0 \) \
\( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args 15x15 -composite \) \
-delete 0,1 -compose multiply -composite result2.png

convert 3.png -auto-level \
\( brown_checks.jpg +duplicate -append +duplicate +append -scale 50% \) \
\( -clone 0 \) \
\( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args 15x15 -composite \) \
-delete 0,1 -compose multiply -composite result3.png

convert 4.png -auto-level \
\( brown_checks.jpg +duplicate -append +duplicate +append -scale 50% \) \
\( -clone 0 \) \
\( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args 15x15 -composite \) \
-delete 0,1 -compose multiply -composite result4.png

convert result2.png result3.png result4.png -background none -flatten result_2_3_4.png
Image

If we do it all combined, we get something similar.

Code: Select all

convert  2.png 3.png 4.png -auto-level -background none -flatten \
\( brown_checks.jpg +duplicate -append +duplicate +append -scale 50% \) \
\( -clone 0 \) \
\( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args 15x15 -composite \) \
-delete 0,1 -compose multiply -composite result234.png
Image

If you want white buttons, then you will need to make an image of only the buttons on a transparent background and then composite it over the results above.

EDIT:

If you do not want the white lines, remove the -auto-level. But it looks too flat for me.

Code: Select all

convert  2.png 3.png 4.png -background none -flatten -brightness-contrast -20,20 \
\( brown_checks.jpg +duplicate -append +duplicate +append -scale 50% \) \
\( -clone 0 \) \
\( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args 15x15 -composite \) \
-delete 0,1 -compose multiply -composite result234b.png
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: apply curv to image

Post by fmw42 »

Just a note:

I had used the following to modify the texture image

Code: Select all

convert brown_checks.jpg +duplicate -append +duplicate +append -scale 50% brown_checks2a.jpg
Image

This was a quick and dirty approach and worked OK, but may have the tendency to show discontinuities. A better method is

Code: Select all

convert brown_checks.jpg \( +clone -flip \) -append \( +clone -flop \) +append -scale 50% brown_checks2b.jpg
Image
vinod
Posts: 20
Joined: 2016-03-10T13:50:05-07:00
Authentication code: 1151

Re: apply curv to image

Post by vinod »

now the time my problem has solved. . . thanks so much for suggestion. . . :)

only cylinder issues is remain .. i am working for this and will ask you for sure. very soon. . thanks so much .. again. . fred. . :)
vinod
Posts: 20
Joined: 2016-03-10T13:50:05-07:00
Authentication code: 1151

Re: apply curv to image

Post by vinod »

sir,

you have given this command

command 1) "convert brown_checks.jpg \( +clone -flip \) -append \( +clone -flop \) +append -scale 50% brown_checks2b.jpg"
and this is my command
command 2) "convert source.png ( -clone 0 -level 50%,100% -alpha off fabric.png -virtual-pixel transparent -compose multiply -composite ) -compose SrcIn -composite output.png"

both command works fine no problems.. but i want to add "displace -set option:compose:args -15x1" in above commands how to add it properly basically in 1st command ?

please help :(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: apply curv to image

Post by fmw42 »

I do not know what you are trying to do. You need to explain in more detail with images provided and what you have tried.

Best guess is what we have done above:

Code: Select all

convert source.png \
\( brown_checks.jpg \( +clone -flip \) -append \( +clone -flop \) +append -scale 50% \) \
\( -clone 0 \) \
\( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args 15x15 -composite \) \
-delete 0,1 -compose multiply -composite result.png
You should review the use of parenthesis processing. See
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#clone
vinod
Posts: 20
Joined: 2016-03-10T13:50:05-07:00
Authentication code: 1151

Re: apply curv to image

Post by vinod »

dear sir,

script is perfect as i want but still i have following things to do in it that

mask.png - Image

red.png - Image

convert mask.png -level 50%,100% -background none -flatten ( red.png +duplicate -append +duplicate +append -scale 50% ) ( -clone 0 ) ( -clone 1 -clone 0 -virtual-pixel transparent -compose displace -set option:compose:args -5x1 -composite ) -delete 0,1 -compose multiply -composite 2.png

this gives me

2.png - Image

and i want 1.png Image

see 2.png again plz , the black mark portion Image

i want that to be like in the image 1.png. . but in 2.png it look flat.. how can i give effect to it ? like in image 1.png
Post Reply