Applying temporal median filter to a video
Date: 2022-11-30 11:58:19
I want to apply Temporal Median Filter to a depth map video to ensure temporal consistency and prevent the flickering effect. Thus, I am trying to apply the filter on all video frames at once by:
First loading all frames,
%%% Read video sequence numfrm = 5; infile_name = 'depth_map_1920x1088_80fps.yuv'; width = 1920; %xdim height = 1088; %ydim fid_in = fopen(infile_name, 'rb'); [Yd, Ud, Vd] = yuv_import(infile_name,[width, height],numfrm); fclose(fid_in); then creating a 3-D depth matrix (height x width x number-of-frames), %%% Build a stack of images from the video sequence stack = zeros(height, width, numfrm); for i=1:numfrm RGB = yuv2rgb(Yd{i}, Ud{i}, Vd{i}); RGB = RGB(:, :, 1); stack(:,:,i) = RGB; end
and finally applying the 1-D median filter along the third direction (time)
temp = medfilt1(stack);
However, for some reason this is not working. When I try to view each frame, I get white images.
frame1 = temp(:,:,1);
imshow(frame1);
Any help would be appreciated!