Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying temporal median filter to a video

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!

like image 572
DML2014 Avatar asked Jan 22 '26 15:01

DML2014


1 Answers

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,

like image 167
Ratbert Avatar answered Jan 24 '26 09:01

Ratbert