Page 1 of 1

Direction of flop() (or flip())

Posted: 2014-07-27T00:42:15-07:00
by kirash4
Following this snippet of code:

Code: Select all

  try {
    list<Image> imagesList;
    Image srcImage(imgFilename);
    Image cloneImg = srcImage;
    imagesList.push_back(srcImage);
    cloneImg.flop();
    imagesList.push_back(cloneImg);

    Montage montageSettings;
    montageSettings.geometry(Geometry(srcImage.columns(), srcImage.rows()));
    montageSettings.tile("2x1");

    list<Image> montageList;
    montageImages(&montageList, imagesList.begin(), imagesList.end(), montageSettings);
    writeImages(montageList.begin(), montageList.end(), flopFilename);
  }
The resulting image is a flop in what I would refer to as a left to right direction (it's flopped along the right edge.) How would I go about making it a right to left direction (flopped along the left edge)? The same for flip(), the resulting image is an upwards flip (along the upper edge). How do I make it a downwards flip (along the bottom edge)? I'd like to make it so the user, when invoking the command, will indicate which direction they want the flip or flop (up/down/left/right).

Re: Direction of flop() (or flip())

Posted: 2014-07-27T10:48:08-07:00
by fmw42
What is the difference between a horizontal mirror between left to right or right to left? No difference as far as I understand. Please clarify.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T11:14:30-07:00
by Bonzo
I think the OP wants to do something like this very rough sketch:
Image

Re: Direction of flop() (or flip())

Posted: 2014-07-27T11:21:19-07:00
by fmw42
I don't understand your diagram, Bonzo. But perhaps they want to mirror and then append.

Code: Select all

convert image \( -clone 0 -flop \) +append result
or the other way

Code: Select all

convert image \( -clone 0 -flop \) +swap +append result
But I do not know the equivalent in any of the APIs.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T11:31:24-07:00
by Bonzo
My sketch was to try and show the options the OP wanted but looking at it I can now see that you are correct.

The mirror along the top is the same result as the mirror along the bottom and the mirror along the edges are the same. Before I looked at my own sketch again I thought they would be different!!

Re: Direction of flop() (or flip())

Posted: 2014-07-27T12:47:44-07:00
by kirash4
The resulting mirror image is the same whether it's a flip or a flop. It's along which edge is what makes the difference in the resulting image:
Image

The code as written performs what I expect it to do. I'm trying to figure out how to go the other direction. Same thing with flip. Both of them seem to have their preferred edge to flop or flip on, so I'm wondering if there's a way to change that edge.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T12:50:35-07:00
by fmw42
As in the code I provide, the way to handle that is to swap the order of the image before appending. I used +swap. I am not sure what the equivalent is in your API, since I only use the command line. But you can change the order of the two images to be appended in any way you can and it should work as you want.

Montage is probably overkill. Look for appendImage or something like that and swapImage or something like that or just change the code to reverse the order of the image in the append or montage statement.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T13:01:24-07:00
by kirash4
I tried changing the order in the montage command, it never worked. Got into a weird loop that just ate up memory and never wrote anything out. I'll see what the swap equivalent is, if there is one for the Magick++ API.

Montage should respect the images, but you may have to do something different about which is the main image.

However, if you change to append rather than montage, it might work. I really don't know how the APIs work with regard to using different order of files. Perhaps it is not so simple. But there should be a way. Nevertheless, if there is a swap, that should work.

Someone who knows your API should be able to help with it. Sorry I cannot help further in that regard.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T13:40:28-07:00
by dlemstra
Shouldn't you just change imagesList.push_back(cloneImg); to imagesList.push_front(cloneImg); ? This will put the images in a different order.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T13:47:26-07:00
by kirash4
dlemstra wrote:Shouldn't you just change imagesList.push_back(cloneImg); to imagesList.push_front(cloneImg); ? This will put the images in a different order.
You'd think, but no. The resulting image is the same.

And changing which gets pushed back first also results in the same thing.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T13:57:31-07:00
by dlemstra
Have you tried using 'appendImages' instead of montage? This should be enough for you. You still need to put the 'cloned flop' at the beginning of your list.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T14:16:58-07:00
by kirash4
Ok, SHOOT ME NOW ... just aim right for the center of my forehead and shoot ... urgh. imagesList.push_front() works as you suggested it should. Except, the file I was editing is not the file that was getting compiled. I was editing -v01 while the IDE was compiling -v02. I just noticed my second computer telling me that -v01 has changed and I went, huh, shouldn't .. then it hit me. I think it's time for me to quit now and go watch a movie or something ... sheesh.

Re: Direction of flop() (or flip())

Posted: 2014-07-27T14:20:20-07:00
by dlemstra
I have absolutely never made such a mistake :)