How can I get median filtered background image from sequence of video frames? I am trying to store the corresponding pixels values of sequence of frames in respective cells and then to find the median value, but I cannot get values in cells.

조회 수: 7 (최근 30일)
files = dir('*.JPG')
img=imread(files(1).name);
img_gray=rgb2gray(img);
E=cell(size(img_gray));
for k = 1:numel(files)
rgb = imread(files(k).name);
gry=rgb2gray(rgb);
for i=1:1:size(gry,1)
for j=1:1:size(gry,2)
E{i,j}=[files(1).name:files(k).name];
med=cellfun(@median,E);
end
end
end

답변 (1개)

Anand
Anand 2014년 3월 5일
Why is E a cell array and why are you using cellfun?
Try using the medfilt2 function instead.
for k = 1 : numel(files)
rgb = imread(files(k).name);
gry = rgb2gray(rgb);
E = medfilt2(gry);
end
  댓글 수: 1
Karthikeyan
Karthikeyan 2014년 3월 5일
I don't want to calculate median for a single image. I want to take (1,1),(1,2),(1,3),...(m,n) pixels from a set of images and then calculate the median for the corresponding pixel of set of images. Simply I want to create a background model from the image sequence using median filter.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by