Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

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! 

Answer: 

My guess is that this is actually working but frame1 is of class double and contains values, e.g. between 0 and 255. As imshow represents double images by default on a [0,1] scale, you obtain a white, saturated image.

I would therefore suggest: 

caxis auto

after imshow to fix the display problem.

Best, 


Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com