Dividing bitmap in two; odd / even line (interlaced) images?

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
eesutton

Dividing bitmap in two; odd / even line (interlaced) images?

Post by eesutton »

Can ImageMagick divide an image into odd-line and even-line image files (interlaced) ?

Background
----------------

Basically I want to created odd and even interlace fields from a single image for the purpose of testing encoding techniques, encoding each field separately, then software deinterlacing to recombine the odd/even fields for subjective quality analysis of camera video. I want to decode and put the two fields back together and compare quality to the original. I could write a utility to split an image pretty quickly but every time I think about doing this I learn that ImageMagick already does this.

Thanks in advance for any examples or direction,

-Ed

PS: I apologize if this appeared twice. I was having trouble joining the mailing list and then I re-discovered this server.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Dividing bitmap in two; odd / even line (interlaced) ima

Post by fmw42 »

Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Dividing bitmap in two; odd / even line (interlaced) ima

Post by Drarakel »

Not sure if ImageMagick has some simple options for handling interlaced video frames. (Probably not?)
A workaround for just extracting the two fields would be (example with a 720x576 PAL frame):

Code: Select all

convert frame.png -depth 8 rgb:- | convert -depth 8 -size 1440x288 rgb:- -crop 50%x100%+0+0 +repage even.png
convert frame.png -depth 8 rgb:- | convert -depth 8 -size 1440x288 rgb:- -gravity northeast -crop 50%x100%+0+0 +repage odd.png
(Of course, one could make a script that works for all input files.)
eesutton

Re: Dividing bitmap in two; odd / even line (interlaced) ima

Post by eesutton »

Excellent! Thank you very much for the examples!

-Ed
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Dividing bitmap in two; odd / even line (interlaced) ima

Post by anthony »

A tricky solution but if you followed the link provided, the better way was a image operation to just ignore every second line... EG use -sample 100x50%\!

If you want the other half, roll the image by one pixel first.

I repeat the link again...
IM Examples, Video Handling, Deinterlacing
http://www.imagemagick.org/Usage/video/#deinterlace
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
eesutton

Re: Dividing bitmap in two; odd / even line (interlaced) ima

Post by eesutton »

Thanks. I will revisit that page again and try to make sense of it.

Thanks again,

-Ed
Post Reply