Monday, July 28, 2008

Interlace, deinterlacing

The input source video is 720x480. After interlace, the even field is 720x240 and the odd field is 720x240. It is often necessary to deinterlace it so that the odd and even lines are interleaved in memory, instead of located in two separate buffers. In my application, we drop one filed and scale the other one to get a 320x240 video.

In normal deinterlacing, an interlaced frame in and get a progressive frame out.

Basic De-interlace methods:
method 1: drop one field (even or odd, called 'line doubling' approach) and do line repetition (row2 = row1) or linear interpolation (row2 = (row1+row3)/2). Or use median filter(don't drop one field): row2 = median(row1, row2, row3).
method 2: if it is still video, combine the even and odd fields (called weave). The drawback (if not still video) is that it causes artifacts related to the fact the two fields are separated by 60 Hz (16.7ms). Drop one field when there are motions. [updated some at 7/12/09]. --So how do you know it is motion? one method is 'spatial adaptive': compare a given pixel to the pixels around it to see if there is a better match between the neighboring area in the other filed (rows above and below) versus its own filed (rows two above and two below). If the neighboring area is a good match, that part of image isn't moving. Another method is 'motion adaptive': compare current frame with a past and future frame to get a better sense of where motion is taking place.[update:12/29/09].
method 3: use motion estimation (complicated and may not get good results in different environment).
Deinterlacing is not re-constructable.
Bob interlace: generate one progressive frame out of each field of the source. It will double the number of frames (it has twice the frame rate) in the video.[update:12/29/09]

With any video system there are trade-offs. One of the most important factors is bandwidth, measured in megahertz (for analog video), or bit rate (for digital video).Interlaced video reduces the signal bandwidth by a factor of two.

When you watch the progressive video on the regular monitor, you cannot get good result.

In our application, the output video is interlacing on monitor (GUI). To get a better result when the camera is moving or there are lots of motions in the scene, de-interlacing may be applied.

== [the following was updated at 10/29/09]
Simulink has a document about deinterlacing. Here is the link
MATLAB code using median filter:

for newline=2:2:size(frame,1)-1
frame(newline,:,:)=median(frame(newline-1:newline+1,:,:),1);
end


No comments:

Post a Comment