In this example, we will demonstrate an alternative method for deinterlacing, based on the averaging of the lines above and below the interlaced one. Since only a minor change will be made in step 3 of the previous process, we will show this process in a little less detail:
First, we will repeat steps 1 and 2 from the previous example, to load our image and preallocate space:
>> A = imread('interlaced.bmp'); % Load interlaced image >> B = uint8(zeros(size(A))); % Pre-allocate space for the result
Before we proceed, we must first convert the input to type single so that the averaging process is not confined to the range of values 0-255:
>> A = single(A); % Convert input to single
Now, we will write the exact same loop as before, with only one minor change; we will replace the line repetition with an averaging process:
>> for i = 1:size(A,1)-1, % For all rows in A (except the last) if mod(i,2) == 0, ...