Manually combine 2 images as interlaced video frame
Posted: Mon Feb 28, 2011 5:19 pm
I'm currently developing a testvideo for automatically detecting field/frame inserts/drops in order to test video A/D converters.
Therefore I needed to manually create images to use as fields.
I'm using ImageMagick to do this. Unfortunately, their information about handling video images is not too much, and mostly involves de-interlacing. So here's how to combine 2 images into a single frame:
1) You need a set of 2 images.
Let's call them:
- top.png
- bottom.png
2) Drop every 2nd line:
Our images have full PAL resolution (since they were manually drawn) and not half the height, like the final field images will have.
First step is to drop every 2nd line and replace it with "black":
The "horizontal2" pattern (=a black line, every 2nd line) must be offset by 1 pixel in order to leave the top line intact (=top field) and mask every even line (=bottom field). So we add "roll +0+1":
The bottom field has its odd lines masked black:
3) Now merge those 2 images into one frame, by using "black" as transparent:
That's it!
Therefore I needed to manually create images to use as fields.
I'm using ImageMagick to do this. Unfortunately, their information about handling video images is not too much, and mostly involves de-interlacing. So here's how to combine 2 images into a single frame:
1) You need a set of 2 images.
Let's call them:
- top.png
- bottom.png
2) Drop every 2nd line:
Our images have full PAL resolution (since they were manually drawn) and not half the height, like the final field images will have.
First step is to drop every 2nd line and replace it with "black":
The "horizontal2" pattern (=a black line, every 2nd line) must be offset by 1 pixel in order to leave the top line intact (=top field) and mask every even line (=bottom field). So we add "roll +0+1":
Code: Select all
convert top.png -size 720x576 pattern:horizontal2 -compose multiply -roll +0+1 -composite top-field.png
Code: Select all
convert bottom.png -size 720x576 pattern:horizontal2 -compose multiply -composite bottom-field.png
Code: Select all
convert top-field.png bottom-field.png -compose screen -composite frame.png