Now it is time to implement the process described in the previous paragraph. The function that we will use is based on the previous two examples:
function [vid] = SpatioTemporalAverage(vid,order) % Function for de-interlacing a video using spatiotemporal averaging % Inputs: % vid – Input video matrix (we assume color video) % order - Choice for row replacement % Output: % vid - Output video matrix (de-interlaced) vid = single(vid); % Convert matrix to single to perform averaging switch order % Checking choice for the order of merging case 1 % Odd rows from odd frames for fr = 2:size(vid,4)-1 % For all frames (but first&last) for row = 2:size(vid,1)-1 % For all rows (but first&last) if mod(fr,2) == 0 % For even frames if mod(row,2) == 0 % Replace even rows vid(row,:,:,fr) = ...((vid(row,:,:,fr-1) + vid(row,:,:,fr...