Info

This question is closed. Reopen it to edit or answer.

i'm getting some errors while executing this coading probably in line no 10,28,and 30.

1 view (last 30 days)
if true
% code
end
clc;
clear all;
close all;
warning off all;
%% Reading Input Video
[filen,pathn]=uigetfile('*.avi','select the avifile','avi'); avi = aviread(filen); frames = {avi.cdata}; a = mmreader([pathn,filen]); vidFrames = read(a); numFrames = get(a,'numberOfFrames'); figure;
%% Frame Extraction
for i=1:length(frames) imshow(frames{i},[]) imwrite(frames{i},['frames/' num2str(i) '.jpg']); pause(0.05) end;
%% Frame Diffrencing
for i = 1:numFrames mov(i).cdata = vidFrames(:,:,:,i); aa = imresize(mov(i).cdata,[256,256]); a1{i} = aa; pause(0.005); end j=1;
for i =1:numFrames-1 a = a1{i}; R1 = a(:,:,1); G1 = a(:,:,2); B1 = a(:,:,3); b = a1{i+1}; R2 = b(:,:,1); G2 = b(:,:,2); B2 = b(:,:,3); D1 = imabsdiff(R1,R2); D2 = imabsdiff(G1,G2); D3 = imabsdiff(B1,B2); D = round(D1+D2+D3); for i2 = 1:size(R1,1) for j2 = 1:size(R1,2) if D(i2,j2)<11 if (R1(i2,j2)<R2(i2,j2)) R1(i2,j2) = R1(i2,j2)+1; else R1(i2,j2) = R1(i2,j2)-1; end if (G1(i2,j2)< G2(i2,j2)) G1(i2,j2) = G1(i2,j2)+1; else G1(i2,j2) = G1(i2,j2)-1; end if (B1(i2,j2)< B2(i2,j2)) B1(i2,j2) = B1(i2,j2)+1; else B1(i2,j2) = B1(i2,j2)-1; end else R1(i2,j2) = R2(i2,j2); G1(i2,j2) = G2(i2,j2); B1(i2,j2) = B2(i2,j2); end end end a(:,:,1) = R1; a(:,:,2) = G1; a(:,:,3) = B1 ; frames{i+1} = a; imshow(D,[]); title('Background Subtracted result'); pause(0.005); end
  1 Comment
Stephen23
Stephen23 on 20 Feb 2015
This is unreadable. Please edit your question and use the {} Code button above the textbox to format your code correctly. You will find the preview frame under the textbox useful as well.

Answers (0)

Community Treasure Hunt

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

Start Hunting!