Hello,
I'm a noob and I'm looking for a command line to interlace two different pictures for almost two days. I've searched on IM's website but I didn't find something like that, maybe I didn't searched well but my english is quite poor .
The thing to do:
line1 from image1 ---> line 1 of new image
line1 from image2 ---> line 2 of new image
line2 from image1 ---> line 3 of new image
line2 from image2 ---> line 4 of new image
and so on...
image1 and image2 are in the same resolution and the new image has 2 times more lines.
I would be very gratefull if someone could explain me how to achieve this.
How to interlace two different images?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to interlace two different images?
Now that is a tricky problem... very very tricky.
The problem is there is no 'shuffle' option to shuffle two image lists together!
Though I proposed one many many years ago!
You can use tile cropping to convert each set of images into a sequence of individual rows,
http://www.imagemagick.org/Usage/crop/#crop_tile
but then you still need to shuffle the two rows together!
However by some imagination I have a solution....
1/ append the two images side by side
2/ tile crop the images into the shuffled rows.
3/ append the separated (and now shuffled) rows vertically!
For example, first two images (both the same size)...
Note: the two rose images Images are 70x46 pixels.
now do the three steps...
If you don't know the size of the image, replace the -crop 70x1 +repage with -crop 0x1 +repage -crop 50%x100% +repage
The other method I thought of was to scale each image by 2, and generate a thrid mask to extract a row from each image alternativally. This used a three image masked composition
http://www.imagemagick.org/Usage/compose/#mask
The mask can be generated using a gray50 pattern image!
So their are two methods you can use. The second is a lot faster as fewer images are involved.
If you want to separate the images again see...
De-Interlacing a video frame
http://www.imagemagick.org/Usage/video/#deinterlace
The problem is there is no 'shuffle' option to shuffle two image lists together!
Though I proposed one many many years ago!
You can use tile cropping to convert each set of images into a sequence of individual rows,
http://www.imagemagick.org/Usage/crop/#crop_tile
but then you still need to shuffle the two rows together!
However by some imagination I have a solution....
1/ append the two images side by side
2/ tile crop the images into the shuffled rows.
3/ append the separated (and now shuffled) rows vertically!
For example, first two images (both the same size)...
Code: Select all
convert rose: image1.png
convert rose: -negate image2.png
now do the three steps...
Code: Select all
convert image1.png image2.png +append \
-crop 70x1 +repage -append \
row_shuffeled_image.png
The other method I thought of was to scale each image by 2, and generate a thrid mask to extract a row from each image alternativally. This used a three image masked composition
http://www.imagemagick.org/Usage/compose/#mask
The mask can be generated using a gray50 pattern image!
Code: Select all
convert image1.png image2.png -scale 100x200%\! \
\( -size 1x92 pattern:gray50 -scale 70x92\! \) \
-composite row_shuffeled_image.png
If you want to separate the images again see...
De-Interlacing a video frame
http://www.imagemagick.org/Usage/video/#deinterlace
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 45
- Joined: 2009-06-29T03:53:05-07:00
- Authentication code: 8675309
- Location: Germany/Munich
Re: How to interlace two different images?
Hi gibbon,gibbon wrote:Hello,
line1 from image1 ---> line 1 of new image
line1 from image2 ---> line 2 of new image
line2 from image1 ---> line 3 of new image
line2 from image2 ---> line 4 of new image
and so on...
image1 and image2 are in the same resolution and the new image has 2 times more lines.
did you find a solution for your problem? If yes, I would be very interested in it. Seems I am looking for the exact same thing...
And just out of curiosity: Why are you trying to combine two different images? Is it possibly two images 1920x1080 with 720 lines of active image each? If yes, give me a ping!
Best, Andreas
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to interlace two different images?
This post might be of interest. viewtopic.php?f=1&t=13483
Re: How to interlace two different images?
I haven't tested this but it might be pretty fast:
1) Append the two images as in anthony's suggestion above
2) write the resulting image as a raw RGB image, which will be same height
and twice as wide as the original
3) read it back as a raw RGB image but with the dimension changed
to the original width and twice the height. (using -size OriginalWidthxTwiceOriginalHeight)
Glenn
1) Append the two images as in anthony's suggestion above
2) write the resulting image as a raw RGB image, which will be same height
and twice as wide as the original
3) read it back as a raw RGB image but with the dimension changed
to the original width and twice the height. (using -size OriginalWidthxTwiceOriginalHeight)
Glenn
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to interlace two different images?
That would be pretty fast, especially in a pipeline, though any meta-data would be lost, and would be slowed from the IO. On the other had with multiple processes it may be faster!
Much of the slowness of my method is all the work IM does to generate all the row images.
The append part is basically just to get the row image order right.
The use of a striped masking image for a compose operation should be quite fast.
Perhaps some speed tests are needed for all three methods is needed. Say at a couple of different sizes. That actual images themselves do not matter for the test.
Much of the slowness of my method is all the work IM does to generate all the row images.
The append part is basically just to get the row image order right.
The use of a striped masking image for a compose operation should be quite fast.
Perhaps some speed tests are needed for all three methods is needed. Say at a couple of different sizes. That actual images themselves do not matter for the test.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/