Displace - Split Source and Displaced Image Possible?

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?".
Post Reply
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Displace - Split Source and Displaced Image Possible?

Post by agriz »

exec("/usr/bin/convert -size 496x709 pattern:HORIZONTALSAW img.png");
exec("/usr/bin/composite img.png source.jpg -displace 50 output.png");

I would like to get the displace image. I don't want the source image.
The displace effect is looking good. How do i get that image alone?

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

Re: Displace - Split Source and Displaced Image Possible?

Post by fmw42 »

I do not think that a binary image pattern such as the saw patterns make for good displacement images as you are doing here. Your img.png is the displacement image.

see
http://www.imagemagick.org/Usage/mappin ... e_displace

Use a different displacement image -- smoother pattern and don't use such a large -displace value. You can see the displaced image in the original because the only parts that are displace are the zigzag and that is shifted 50 right and 50 down. Look at the red lines coming from her red top.

The fact that you zigzag is binary is why the two images seem overlapped. Some parts are displaced and others not.
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Displace - Split Source and Displaced Image Possible?

Post by agriz »

composite {displacement_map} {input_image} -displace {X}x{Y} {result}
According to this example,
img.png is the displacement_map
source.png is the input_image
and output.png is the result

Is that black border, i drawn, the displaced image of original image?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Displace - Split Source and Displaced Image Possible?

Post by anthony »

For just the displaced image, use the displacement image simply as a mask instead.

Unless I am not understanding 'I would like to get the displace image.'


Warning -displace 50, displaces 50 pixels in BOTH the X and Y directions.
See Image Mapping Effects
http://www.imagemagick.org/Usage/mappin ... ement_maps
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: Displace - Split Source and Displaced Image Possible?

Post by fmw42 »

It is a portion of the displaced part. But there are other displaced parts that you have missed.

I suspect that what you really want is just to:

composite img.png source.png -compose multiply result.png

or -negate your img.png

one or the other may give you want you want.

If you want to shift that result, then use +distort SRT


Note composite is really getting very outdated and will likely go away in IM 7. So I suggest you start using convert ... -compose xxx -composite ...

The convert approach is much more flexible, has more options and is the more modern IM 6 syntax.

see
http://www.imagemagick.org/script/compose.php
http://www.imagemagick.org/Usage/layers/#convert
Last edited by fmw42 on 2012-03-04T22:35:33-07:00, edited 2 times in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Displace - Split Source and Displaced Image Possible?

Post by anthony »

For interger pixel shifts you can also use something like.

Code: Select all

-repage +{X}+{Y} -background {COLOR} -flatten
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Displace - Split Source and Displaced Image Possible?

Post by agriz »

-negate gave me good effect.
I am working on different value on -repage with different bg color.

There is lot and lot to learn in imagemagick :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Displace - Split Source and Displaced Image Possible?

Post by fmw42 »

agriz wrote: There is lot and lot to learn in imagemagick :)

Quite true! Keep up the study and practice.
Post Reply