Code: Select all
convert ./one.mpc ./two.mpc ./three.mpc -channel rgba -alpha on -virtual-pixel background -background none -define compose:args=6000x254.91 -compose displace -composite ./one.mpc
Code: Select all
convert ./one.mpc ./two.mpc ./three.mpc -channel rgba -alpha on -virtual-pixel background -background none -define compose:args=6000x254.91 -compose displace -composite ./one.mpc
yes,
Code: Select all
convert one.png -channel rgba -alpha on -virtual-pixel background -background none -define compose:args=6000x254.91 oneM.png
convert two.png -channel rgba -alpha on -virtual-pixel background -background none -define compose:args=6000x254.91 twoM.png
convert three.png -channel rgba -alpha on -virtual-pixel background -background none -define compose:args=6000x254.91 threeM.png
convert oneM.png twoM.png -compose displace -composite oneC1.png
convert oneC1.png threeM.png -compose displace -composite oneC2.png
This will displace pixels by amounts defined in the second image (which is a relative displacement map). But you need "-define compose:args={stuff}"rpatelob wrote:convert oneM.png twoM.png -compose displace -composite oneC1.png
Code: Select all
convert oneM.png twoM.png threeM.png -compose displace -composite oneC1.png
For above commands I wrote C code like this.rpatelob wrote: ↑2017-04-19T04:35:09-07:00Code: Select all
convert ./one.mpc ./two.mpc ./three.mpc -channel rgba -alpha on -virtual-pixel background -background none -define compose:args=6000x254.91 -compose displace -composite ./one.mpc
Code: Select all
MagickSetImageAlphaChannel(wand, RGBChannels);
MagickSetImageVirtualPixelMethod(wand, BackgroundVirtualPixelMethod);
MagickSetImageBackgroundColor(wand, PW1);
char cmpArgs[50];
sprintf(cmpArgs,"%zu%s%f",xc,"x",radius2);
MagickSetImageArtifact(wand, "compose:args", cmpArgs);
MagickSetImageAlphaChannel(wand2, RGBChannels);
MagickSetImageVirtualPixelMethod(wand2, BackgroundVirtualPixelMethod);
MagickSetImageBackgroundColor(wand2, PW1);
MagickSetImageArtifact(wand2, "compose:args", cmpArgs);
MagickSetImageAlphaChannel(wand3, RGBChannels);
MagickSetImageVirtualPixelMethod(wand3, BackgroundVirtualPixelMethod);
MagickSetImageBackgroundColor(wand3, PW1);
MagickSetImageArtifact(wand3, "compose:args", cmpArgs);
MagickCompositeImage(wand, wand2, DisplaceCompositeOp,MagickFalse, 0, 0);
MagickCompositeImage(wand, wand3, DisplaceCompositeOp,MagickFalse, 0, 0);
MagickWriteImage(wand,"final.png");
Code: Select all
convert one.png two.png three.png -compose displace -composite cylinderCMD.png
Code: Select all
MagickCompositeImage(wand, wand2, DisplaceCompositeOp,MagickFalse, 0, 0);
MagickCompositeImage(wand, wand3, DisplaceCompositeOp,MagickFalse, 0, 0);
MagickWriteImage(wand,"final.png");
I'm a newbie in ImageMagick, I did not understand what you said. Could you please provide me one example in C?snibgo wrote: ↑2017-04-20T01:44:29-07:00 Above, I said that when a composite has three inputs images, the third is a mask.
I had forgotten that this is not true for displace or distort composites. For these, the second image is the x-displacement, and the third image is the y-displacement. So there are two (grayscale) distortion maps, not one (colour) distortion map and a mask. See http://www.imagemagick.org/Usage/mapping/#distort and the code in wand\composite.c CompositeImageCommand().
To replicate this action in C code, clone the first grayscale map, and replace the green channel with the second grayscale map. Then call MagickCompositeImage() with this colour map.
Code: Select all
convert two.png three.png +clone -combine displaceMask.png
convert one.png displaceMask.png -compose displace -composite final.png