How to warp two images together when compositing them.

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
coolperez8
Posts: 27
Joined: 2016-03-11T07:27:11-07:00
Authentication code: 1151

How to warp two images together when compositing them.

Post by coolperez8 »

So, what I want to do is use composite to compose two stereoscopic images together so the top row of pixels display the left side image and the bottom row of pixels display the right side image. Here's what I did.

1.I have 2 720x720 stereoscopic images where one is the left camera and the other is the right camera.
2.I generate a 720x720 gradient using this command:

Code: Select all

convert -size 720x720 gradient: grad0000.png
3.I composite the images as so:

Code: Select all

convert "../left/%name%" "../right/%name%" grad0000.png -composite morp0000.png
The problem here is that while the top row does display the left side image and the bottom row displays the right side image, everything in between is faded together, which isn't typical for my usage. What I want it to do for the pixels in between is morph the images together so it looks seamless rather then fade/blend the images together. The reason for this is because I'm using Blender to generate stereoscopic 3D videos and am using a cubemap method in another program to export the videos in 3D in Blender, but apparently the top and bottom images don't line up with the back unless I switch the left/right images on the top and bottom or back image, and switching them on the back would cause the 3D effect to be lost.

Another thing that would be greatly appreciated is if there was a way to render stereoscopic 3D images directly from within ImageMagick itself without having to use Blender, if each of the 6 sides of the cube had a left and right image for it, the images were widescreen, and I wanted ImageMagick to blend them together in a smart way in order to make it look "seamless". Note that for these images the top and bottom image line up correctly with the front in both left and right, but they almost line up correctly with the back if I switch the left/right images on either the top/bottom or back.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to warp two images together when compositing them.

Post by snibgo »

coolperez8 wrote:What I want it to do for the pixels in between is morph the images together so it looks seamless rather then fade/blend the images together.
Put this another way: you have two images, as if a camera viewed a scene from two positions. You want each row of the output to be as if viewed from intermediate positions. Is that correct? I don't think IM can do that. To do that, software needs to reconstruct 3D information, which IM doesn't do.

I think you need to tell your 3D software to construct the appropriate number of images, then crop each image to just one row, and append them together. This wouldn't be difficult in Blender.

But perhaps I misunderstand. It would help if you showed sample images. And tell us what version of IM you use, on what platform.
snibgo's IM pages: im.snibgo.com
coolperez8
Posts: 27
Joined: 2016-03-11T07:27:11-07:00
Authentication code: 1151

Re: How to warp two images together when compositing them.

Post by coolperez8 »

snibgo wrote: 2019-01-31T08:17:17-07:00
coolperez8 wrote:What I want it to do for the pixels in between is morph the images together so it looks seamless rather then fade/blend the images together.
Put this another way: you have two images, as if a camera viewed a scene from two positions. You want each row of the output to be as if viewed from intermediate positions. Is that correct? I don't think IM can do that. To do that, software needs to reconstruct 3D information, which IM doesn't do.

I think you need to tell your 3D software to construct the appropriate number of images, then crop each image to just one row, and append them together. This wouldn't be difficult in Blender.

But perhaps I misunderstand. It would help if you showed sample images. And tell us what version of IM you use, on what platform.
I was able to get somewhat of a result by copying the left frame into a folder with number 000000 and the right frame into the same folder as 000001, 000002, and 000003, then using FFmpeg to motion interpolate it from 2 fps to 720 fps but limit the number of frames to 720. (The 3 and 4 are needed or FFmpeg refuses to output). Then I cropped each image to the row number, appended them, and it kinda worked.
Post Reply