我在框架上使用Back round减法方法。现在我想查看这些框架的预览。但是出现错误“
未定义函数'预览'用于'struct'类型的输入参数这是代码:
for i = 2:numFrames
%fr = vid(i).cdata;
% read in frame
fr= read(vid, i);
fr_bw = rgb2gray(fr); % convert frame to grayscale
fr_diff = abs(double(fr_bw) - double(bg_bw)); % cast operands as double to avoid negative overflow
threshHold=mean(fr_diff);%Experimetn
for j=1:width % if fr_diff > thresh pixel in foreground
for k=1:height
if ((fr_diff(k,j) > threshHold))
fg(k,j) = fr_bw(k,j);
else
fg(k,j) = 0;
end
end
end
bg_bw = fr_bw; %store old frame to bg_bw variable
imshow(fr_bw);
figure(1),subplot(3,1,1),imshow(fr)
subplot(3,1,2),imshow(fr_bw)
subplot(3,1,3),imshow(uint8(fg)) ;
z=i-1;
q(z) = im2frame(uint8(fg),gray(256)); % put frames into movie
preview((q(z)));
end