Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!y23g2000yqd.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Need urgent help in video image processing
Date: Thu, 29 Oct 2009 05:19:00 -0700 (PDT)
Organization: http://groups.google.com
Lines: 53
Message-ID: <b66b1331-1969-4975-a94c-99060efe3d92@y23g2000yqd.googlegroups.com>
References: <hcanq2$qfi$1@fred.mathworks.com> <b86f3483-1873-4911-9dce-6f6824993c5c@v30g2000yqm.googlegroups.com> 
	<hcavtc$au4$1@fred.mathworks.com> <7P7Gm.14$v47.9@newsfe23.iad> 
	<hcb891$bhr$1@fred.mathworks.com> <uP9Gm.16543$6q1.11334@newsfe17.iad>
NNTP-Posting-Host: 192.44.136.113
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1256818741 12743 127.0.0.1 (29 Oct 2009 12:19:01 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 29 Oct 2009 12:19:01 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: y23g2000yqd.googlegroups.com; posting-host=192.44.136.113; 
	posting-account=0rLUzAkAAABojYSRC64DkTbtiSCX77HH
User-Agent: G2/1.0
X-HTTP-Via: 1.1 bdci2px (NetCache NetApp/6.0.7)
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; 
	CyberSafe-IWA-Enable; .NET CLR 1.1.4322; .NET CLR 2.0.50727; MS-RTC LM 8; 
	.NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 
	3.5.30729),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:580928


Syed Ali:
See if this demo will help you.

%------------------------------------------------------------------------------------------------------------------
% Demo m-file to extract and write out all the frames of an avi movie
to disk.
% by ImageAnalyst
clc;
close all;
filename = 'C:\Program Files\MATLAB\R2008b\toolbox\images\imdemos
\rhinos.avi';
mov = aviread(filename);
% movie(mov);
outputFolder = fullfile(cd, 'Rhino Movie');
if ~exist(outputFolder, 'dir')
	mkdir(outputFolder);
end
numberOfFrames = size(mov, 2);
numberOfFramesWritten = 0;
for frame = 1 : numberOfFrames
	thisFrame = mov(frame).cdata;
	outputBaseFileName = sprintf('Frame %4.4d.png', frame);
	outputFullFileName = fullfile(outputFolder, outputBaseFileName);
	imwrite(thisFrame, outputFullFileName, 'png');
	progressIndication = sprintf('Wrote frame %4d of %d.', frame,
numberOfFrames);
	disp(progressIndication);
	numberOfFramesWritten = numberOfFramesWritten + 1;
end
progressIndication = sprintf('Wrote %d frames to folder "%s"',
numberOfFramesWritten, outputFolder);
disp(progressIndication);


I'm not sure if you really wanted 1, 15, 30, 45, etc. instead of 1,
16, 31, 46, etc. but I'll just assume you meant what you said.  You'll
need to change the for loop to something like this because of your
strange incrementing (14 for the first one and 15 after that).
for frame = 0 : 15 : numberOfFrames
  if frame == 0
	thisFrame = mov(1).cdata;
  else
	thisFrame = mov(frame).cdata;
  end

Now, when you subtract, you'll have to cast your frames to int16,
int32, single, or double BEFORE the subtraction, because your
differences could go from -255 to +255 and uint8 will clip any
negative values to 0 so you'll lose them.  You don't have to write out
anything (original frames or subtracted ones) if you don't want to so
you can remove those lines if you want.
Good luck,
ImageAnalyst