Page 1 of 1

Anyone please explain me below command.

Posted: 2017-04-19T04:35:09-07:00
by rpatelob

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
What I understood is it takes three images and apply all the effects on all three images and finally merge into one.

Re: Anyone please explain me below command.

Posted: 2017-04-19T04:56:16-07:00
by snibgo
Yes, that's correct. Do you have a question?

Re: Anyone please explain me below command.

Posted: 2017-04-19T05:19:23-07:00
by rpatelob
snibgo wrote: 2017-04-19T04:56:16-07:00 Yes, that's correct. Do you have a question?
yes,
Is it equal to these set of commands?

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

Re: Anyone please explain me below command.

Posted: 2017-04-19T05:45:43-07:00
by snibgo
No, it's not the same. PNG files don't record "-virtual-pixel background" etc. So these settings have no effect in the multiple commands.
rpatelob wrote:convert oneM.png twoM.png -compose displace -composite oneC1.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}"

When you have three inputs to "-composite", the third input image is a mask for the composite. I've never done masked displacements (I simply modify the map), and I'm not sure result I would want, or what the result should be, or what it actually is.

Re: Anyone please explain me below command.

Posted: 2017-04-19T06:07:49-07:00
by rpatelob
Yes, because when I ran below command I got the result but with individuals not.

Code: Select all

convert oneM.png twoM.png threeM.png -compose displace -composite oneC1.png
Actually I'm trying to achieve same result with MagickWand C API. But I don't know how to merge three images together with composite.
Here is the MagickWand Composite https://www.imagemagick.org/api/magick- ... ositeImage

Re: Anyone please explain me below command.

Posted: 2017-04-19T06:15:58-07:00
by snibgo
If you have an image that you want to displace by a map, and then displace the result by a second map, then you can do exactly that. Call MagickCompositeImage() twice.

Re: Anyone please explain me below command.

Posted: 2017-04-19T06:24:02-07:00
by rpatelob
rpatelob wrote: 2017-04-19T04:35:09-07:00

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
For above commands I wrote C code like this.

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");

Re: Anyone please explain me below command.

Posted: 2017-04-19T07:14:48-07:00
by snibgo
Your C code doesn't match your command. The command is a masked composite, and I don't think you want that.

I suggest you find what command does what you want. Do that first. Then, implement it in C code.

Re: Anyone please explain me below command.

Posted: 2017-04-20T00:17:22-07:00
by rpatelob
one.png
Image

two.png
Image

three.png
Image

These are my images. If I simply run

Code: Select all

convert one.png two.png three.png -compose displace -composite cylinderCMD.png
command, I get the similar output image that I want. For full working C code, please check http://stackoverflow.com/questions/4349 ... nds-into-c this link. It should be work with below code but may be I missed something on it.

Code: Select all

 MagickCompositeImage(wand, wand2, DisplaceCompositeOp,MagickFalse, 0, 0);
 MagickCompositeImage(wand, wand3, DisplaceCompositeOp,MagickFalse, 0, 0);
 MagickWriteImage(wand,"final.png");


cylinderCMD.png
Image

Re: Anyone please explain me below command.

Posted: 2017-04-20T01:44:29-07:00
by snibgo
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.

Re: Anyone please explain me below command.

Posted: 2017-04-20T03:58:54-07:00
by rpatelob
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.
I'm a newbie in ImageMagick, I did not understand what you said. Could you please provide me one example in C?

Re: Anyone please explain me below command.

Posted: 2017-04-20T04:25:15-07:00
by snibgo
See wand\composite.c, function CompositeImageCommand().

Re: Anyone please explain me below command.

Posted: 2017-04-25T05:47:42-07:00
by rpatelob
Got the sollution. I just need to merge two.png and three.png images together and apply displace composite with one.png. below is the alternative command for this. Finally I converted it to C and it worked.

Code: Select all

convert two.png three.png +clone -combine displaceMask.png
convert one.png  displaceMask.png -compose displace -composite final.png