Anyone please explain me below command.

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
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Anyone please explain me below command.

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Anyone please explain me below command.

Post by snibgo »

Yes, that's correct. Do you have a question?
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: Anyone please explain me below command.

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Anyone please explain me below command.

Post 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.
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: Anyone please explain me below command.

Post 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
Last edited by rpatelob on 2017-04-19T06:25:10-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Anyone please explain me below command.

Post 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.
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: Anyone please explain me below command.

Post 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");
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Anyone please explain me below command.

Post 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.
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: Anyone please explain me below command.

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Anyone please explain me below command.

Post 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.
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: Anyone please explain me below command.

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Anyone please explain me below command.

Post by snibgo »

See wand\composite.c, function CompositeImageCommand().
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: Anyone please explain me below command.

Post 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
Post Reply