Time for action – deinterlacing a video using the vision toolbox

The Computer Vision System Toolbox has an object that can handle three common methods of deinterlacing. The object is intuitively called Deinterlacer. Let's see its usage on our example interlaced image.

  1. First, we have to load our image. If you have cleared your workspace, type the following command:
    >> A = imread('interlaced.bmp'),	  % Load interlaced image
  2. Then, we have to initialize the Deinterlacer object. Let's use the default settings:
    >> deintObj = vision.Deinterlacer; % create deinterlacing System object 
  3. Now it is time to apply the deinterlacing method specified by the default settings (line repetition method) to our interlaced frame:
    >> A2 = step(deintObj, A); % Apply de-interlacing method
  4. Finally, we will see the before and after images and cropped parts, side-by-side:
    >> B = imcrop(A,[480 400 200 100]); % Crop interlaced detail 
    >> B2 = imcrop(B,[480 400 200 100]); % Crop deinterlaced detail 
    >> subplot(2,2,1),imshow(A);title('Entire Interlaced Frame')
    >> subplot(2,2,2),imshow(A2);title('EntireDe-Interlaced Frame')
    >> subplot(2,2,3),imshow(B);title('Cropped Interlaced Area')
    >> subplot(2,2,4),imshow(B2);title('Cropped De-Interlaced Area')
    Time for action – deinterlacing a video using the vision toolbox

What just happened?

This example demonstrated the usage of the Deinterlacer object of the Computer Vision System Toolbox, with the default method setting, which is the line repetition. As the name implies, this method deinterlaces an image by repeating the odd (or even) lines to replace the even (or odd) lines, keeping the overall image size the same. The effect was obviously positive, as the jagged artifacts on the edges of the car have been significantly reduced. The repetition of lines was probably the simplest way to solve the problem. The process, as shown in the example, was quite simple; first we loaded our interlaced image, then we initialized a deinterlacing System object, and we called the step method to apply the process (deinterlacing) to our target input (the interlaced image). The final step was useful for a qualitative evaluation of the success of our method. From its results, we can see that even with the simplest method the deinterlaced result looks better than the interlaced input.

Have a go hero – comparing the deinterlacing methods

Now it is time for you to tweak the settings of the Deinterlacer object. You should try to initialize three different objects, one for each method (line repetition, linear interpolation, and vertical temporal median filtering). Apply all of them to the interlaced image and compare the same cropped area as before. If you implement the described process successfully, you should get an image like the one that follows:

Have a go hero – comparing the deinterlacing methods

You should also try to experiment with other areas of the image, so that you get a better idea of the pros and cons of each method depending on the content of the image.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset