texture , effect 3D

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?".
stefek143
Posts: 8
Joined: 2012-04-06T03:10:56-07:00
Authentication code: 8675308

texture , effect 3D

Post by stefek143 »

it's possible to do something like this? :

Image

+ texture

result:
Image

I was found in internet that php script doing such effect, and I think with use imagemagick but how it is possible?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: texture , effect 3D

Post by anthony »

I believe they would start with a flat texture image, then 'warp' it using a pre-generated 'distort or displacement map' Shading and overlaying would then be applied.

See IM Examples, Image Mapping Effects, Distorts and Displacements
http://www.imagemagick.org/Usage/mapping/#distort
whcih will introduce you to the concepts.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: texture , effect 3D

Post by fmw42 »

Sometimes you can take the graytone image and adjust its contrast and brightness and use that for the displacement map.

see examples at
viewtopic.php?f=1&t=16921&p=62696&hilit ... irt#p62696
viewtopic.php?f=1&t=20455&p=81771&hilit ... ace#p81771

But as Anthony says, you may have to adjust the displacement map or create a better one.


I have not given this much thought, but perhaps one can take the shoe and make it binary (b/w) and then use -morphology distance to create a grayscale displacement map. see http://www.imagemagick.org/Usage/morphology/#distance
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: texture , effect 3D

Post by anthony »

I don't thnk mathematical methods would work well here.

The definate bend and compession along the top surface to make it look right needs some work.

One way to help with this is to get photos of a object with a checkerboard pattern to it. The check corners can then be used to define control points in setting up the distortion/displacement map needed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
stefek143
Posts: 8
Joined: 2012-04-06T03:10:56-07:00
Authentication code: 8675308

Re: texture , effect 3D

Post by stefek143 »

souonds like very hard to do.. maybe smb will do some simple example how to put similiar texture on such shoe?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: texture , effect 3D

Post by fmw42 »

stefek143 wrote:souonds like very hard to do.. maybe smb will do some simple example how to put similiar texture on such shoe?
smb -- what or who is that?
stefek143
Posts: 8
Joined: 2012-04-06T03:10:56-07:00
Authentication code: 8675308

Re: texture , effect 3D

Post by stefek143 »

smb - somebody ;-)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: texture , effect 3D

Post by fmw42 »

I don't think anyone here knows exactly how to do that without using 3D modeling and texture mapping software. IM does is only a 2D image processor. So there is only so much it can do.

You have been given ideas with which to experiment. I think that is the best we can do. If some one else has any ideas, I am sure they will add their comments or examples.

Do you have the original texture image that you want to overlay onto the shoe? If so, post that as well, otherwise no one can do any testing to compare to your result.
Last edited by fmw42 on 2012-04-10T20:51:25-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: texture , effect 3D

Post by anthony »

It should not be hard to do. Just need a little artisty in a image editor like gimp to generate the maps.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
stefek143
Posts: 8
Joined: 2012-04-06T03:10:56-07:00
Authentication code: 8675308

Re: texture , effect 3D

Post by stefek143 »

I'm trying to do some gradient maps(with use photoshop), but unfortunatly any good results, the main problem is area what I marked on the picture.

PS. for me no matter is texture like on picture or not, I just want to do such effect.

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

Re: texture , effect 3D

Post by fmw42 »

If you want others to try something, we need the original texture image that you are trying to put on the shoe.
stefek143
Posts: 8
Joined: 2012-04-06T03:10:56-07:00
Authentication code: 8675308

Re: texture , effect 3D

Post by stefek143 »

for example this texture:

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

Re: texture , effect 3D

Post by fmw42 »

It would have been nicer to have the same original texture image so that one can compare.

Nevertheless, your texture image is not the same size as your shoe image, so it needs to be stretched. But try this. It is the very same technique used in the two examples listed above for similar things.

(Change the amount below to make the distortion increase)

(NOTE for ease of my use, I renamed images and I added 1 as a prefix to all images)

amount=5

convert \( 1dollar.jpg -resize 180x151! \) \( 1shoe.jpg -auto-level \) \
-virtual-pixel transparent -compose displace \
-set option:compose:args -${amount}x-${amount} -composite 1dollar_dm${amount}.png

convert 1shoe.jpg 1dollar_dm${amount}.png \( -clone 0 -threshold 55% \) \
-compose over -composite 1shoe_1dollar_dm${amount}_comp.png

Image

Note I did -auto-level on the shoe so as the make the effect more intense in the first command
I also thresholded the shoe to make a mask for compositing the texture over the shoe in the second command

This is effectively a "shape from shading" method using the shading as a displacement map.

P.S. It occurs to me that some of the "effect" may just be coming from the stretched overlay image. So a larger image that can be cropped to the right size, might be a better indication.

So I made a grid pattern

convert -size 180x151 pattern:hs_cross 1grid.png

Image


Then applied the same processing:

amount=5
convert 1grid.png \( 1shoe.jpg -auto-level \) \
-virtual-pixel transparent -compose displace \
-set option:compose:args -${amount}x-${amount} -composite 1grid_dm${amount}.png


convert 1shoe.jpg 1grid_dm${amount}.png \( -clone 0 -threshold 55% \) \
-compose over -composite 1shoe_1grid_dm${amount}_comp.png

Image
stefek143
Posts: 8
Joined: 2012-04-06T03:10:56-07:00
Authentication code: 8675308

Re: texture , effect 3D

Post by stefek143 »

thank you !

your effect is really god but one main thing I dont see, please look on my picture :

Image

as you can see the area what I've marked in this place has effect like "arch", texture(dollar) begin from the top and go down with "arch effect" and this make effect 3D. On texture with letters (few posts above) is possible to better see. Letter move from top to bottom without deformation and all of this make 3D effect.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: texture , effect 3D

Post by fmw42 »

I am not sure I understand what you think is wrong. Try increasing the amount parameter to increase the effect. Otherwise you may have to manually paint the mask to change the shading to get the effect you want.
Post Reply