<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395</link>
    <title>MATLAB Central Newsreader - Need urgent help in video image processing</title>
    <description>Feed for thread: Need urgent help in video image processing</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 29 Oct 2009 00:32:03 -0400</pubDate>
      <title>Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#690492</link>
      <author>Syed Ali</author>
      <description>Hi, every one. I am new to MATLAB. I am trying to make &lt;br&gt;
a short program for learning, but still having difficulties. &lt;br&gt;
I have a movie in AVI format of 816 frames. I want to &lt;br&gt;
read each frame, each pixel in the frame and then &lt;br&gt;
take out the difference of frames after every 15 frames&lt;br&gt;
and show the result. I got it by using following code:&lt;br&gt;
&lt;br&gt;
test_vid = aviread('road.avi');&lt;br&gt;
siz_vid = size(test_vid);&lt;br&gt;
fram_cap = imshow(test_vid(1).cdata);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
then i stuck, &lt;br&gt;
could any one can help me out in coding.&lt;br&gt;
Regards&lt;br&gt;
Syed</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 02:04:44 -0400</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#690499</link>
      <author>ImageAnalyst</author>
      <description>On Oct 28, 8:32&#160;pm, &quot;Syed Ali&quot; &amp;lt;sfaisalal...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi, every one. I am new to MATLAB. I am trying to make&lt;br&gt;
&amp;gt; a short program for learning, but still having difficulties.&lt;br&gt;
&amp;gt; I have a movie in AVI format of 816 frames. I want to&lt;br&gt;
&amp;gt; read each frame, each pixel in the frame and then&lt;br&gt;
&amp;gt; take out the difference of frames after every 15 frames&lt;br&gt;
&amp;gt; and show the result. I got it by using following code:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; test_vid = aviread('road.avi');&lt;br&gt;
&amp;gt; siz_vid = size(test_vid);&lt;br&gt;
&amp;gt; fram_cap = imshow(test_vid(1).cdata);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; then i stuck,&lt;br&gt;
&amp;gt; could any one can help me out in coding.&lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; Syed&lt;br&gt;
&lt;br&gt;
-------------------------------------------------------------------------------------&lt;br&gt;
Please define more explicitly what &quot;then take out the difference of&lt;br&gt;
frames after every 15 frames &quot; means.</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 02:50:21 -0400</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#690508</link>
      <author>Syed Ali</author>
      <description>Sir, &lt;br&gt;
Let suppose I have a file name traffic.avi.&lt;br&gt;
I need to find out that is there any motion in it or not, for this&lt;br&gt;
I need to take all the frames from the movie &quot;traffic.avi&quot;.&lt;br&gt;
Then I will select only frames from 1, 15, 30, 45,..... end, &lt;br&gt;
Then I will read each frame pixel by pixel and then store them &lt;br&gt;
as frame 1, frame 15, frame 30, ... end.&lt;br&gt;
Later on I will start doing subtraction &lt;br&gt;
so frame_60 - frame_45 , frame_45 - frame_30, ...&lt;br&gt;
then display the result as a movie or images, so i can find &lt;br&gt;
out that either any of the object which is in frame 1 is moving&lt;br&gt;
or not. The problem is when i am using aviread, the MATLAB&lt;br&gt;
creates the structure having all my frames in it, &lt;br&gt;
in cdata and map, then I dont know how to get excess&lt;br&gt;
of each frame and how to read the values from each frame.&lt;br&gt;
Hope you can understand.&lt;br&gt;
Regards&lt;br&gt;
Syed,</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 03:17:22 -0400</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#690510</link>
      <author>Nasser M. Abbasi</author>
      <description>&lt;br&gt;
&quot;Syed Ali&quot; &amp;lt;sfaisalalipk@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:hcavtc$au4$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Sir,&lt;br&gt;
&amp;gt;&lt;br&gt;
The problem is when i am using aviread, the MATLAB&lt;br&gt;
&amp;gt; creates the structure having all my frames in it,&lt;br&gt;
&amp;gt; in cdata and map, then I dont know how to get excess&lt;br&gt;
&amp;gt; of each frame and how to read the values from each frame.&lt;br&gt;
&lt;br&gt;
Well, then why don't you just read the specific frames from the file?&lt;br&gt;
&lt;br&gt;
from help&lt;br&gt;
&lt;br&gt;
&quot;mov = aviread(filename, index) reads only the frames specified by index. &lt;br&gt;
index can be a single index or an array of indices into the video stream. In &lt;br&gt;
AVI files, the first frame has the index value 1, the second frame has the &lt;br&gt;
index value 2, and so on.&quot;&lt;br&gt;
&lt;br&gt;
--Nasser</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 05:13:05 -0400</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#690521</link>
      <author>Syed Ali</author>
      <description>Dear Brother Naseer, &lt;br&gt;
Thanks for your guidence, but do guide me, &lt;br&gt;
for a frame &lt;br&gt;
fram_test = aviread('abc.avi');&lt;br&gt;
In work space it creates a structure &amp;lt;1 X 816&amp;gt; means it can have 816 frames.&lt;br&gt;
Now further if we browse it will be &lt;br&gt;
fram_test(1,1) will have cdata and colormap.&lt;br&gt;
Now in cdata &amp;lt;240 X 320 X 3&amp;gt; 8 units. &lt;br&gt;
The problem is how I can read pixel by pixel from each frame so &lt;br&gt;
I can have single value of pixels (R, G, B) from each frame.&lt;br&gt;
Thanks &lt;br&gt;
Regards&lt;br&gt;
Syed</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 05:34:17 -0400</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#690523</link>
      <author>Nasser M. Abbasi</author>
      <description>&lt;br&gt;
&quot;Syed Ali&quot; &amp;lt;sfaisalalipk@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:hcb891$bhr$1@fred.mathworks.com...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Now in cdata &amp;lt;240 X 320 X 3&amp;gt; 8 units.&lt;br&gt;
&amp;gt; The problem is how I can read pixel by pixel from each frame so&lt;br&gt;
&amp;gt; I can have single value of pixels (R, G, B) from each frame.&lt;br&gt;
&lt;br&gt;
I do not know the avi stuff much, but the above seems like a common layout.&lt;br&gt;
&lt;br&gt;
You have a frame which is made up of 3 channels (i.e. color frame). So the &lt;br&gt;
first channel is the first page of the 3-D matrix, the second channel is the &lt;br&gt;
second page, etc...&lt;br&gt;
&lt;br&gt;
I do not know which is which, assume cdata(:,:,1) is R, cdata(:,:,2) is G &lt;br&gt;
and cdata(:,:,3) is the blue.&lt;br&gt;
&lt;br&gt;
So just read each pixel as you would normally read 3-D matrix?&lt;br&gt;
&lt;br&gt;
the first pixel has its R pixel located at cdata(1,1,1), and has green pixel &lt;br&gt;
at (1,1,2) etc...&lt;br&gt;
&lt;br&gt;
each pixel value is 8 bits of intensity. so has value of 0..255&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
--Nasser</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 12:19:00 -0400</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#690611</link>
      <author>ImageAnalyst</author>
      <description>Syed Ali:&lt;br&gt;
See if this demo will help you.&lt;br&gt;
&lt;br&gt;
%------------------------------------------------------------------------------------------------------------------&lt;br&gt;
% Demo m-file to extract and write out all the frames of an avi movie&lt;br&gt;
to disk.&lt;br&gt;
% by ImageAnalyst&lt;br&gt;
clc;&lt;br&gt;
close all;&lt;br&gt;
filename = 'C:\Program Files\MATLAB\R2008b\toolbox\images\imdemos&lt;br&gt;
\rhinos.avi';&lt;br&gt;
mov = aviread(filename);&lt;br&gt;
% movie(mov);&lt;br&gt;
outputFolder = fullfile(cd, 'Rhino Movie');&lt;br&gt;
if ~exist(outputFolder, 'dir')&lt;br&gt;
	mkdir(outputFolder);&lt;br&gt;
end&lt;br&gt;
numberOfFrames = size(mov, 2);&lt;br&gt;
numberOfFramesWritten = 0;&lt;br&gt;
for frame = 1 : numberOfFrames&lt;br&gt;
	thisFrame = mov(frame).cdata;&lt;br&gt;
	outputBaseFileName = sprintf('Frame %4.4d.png', frame);&lt;br&gt;
	outputFullFileName = fullfile(outputFolder, outputBaseFileName);&lt;br&gt;
	imwrite(thisFrame, outputFullFileName, 'png');&lt;br&gt;
	progressIndication = sprintf('Wrote frame %4d of %d.', frame,&lt;br&gt;
numberOfFrames);&lt;br&gt;
	disp(progressIndication);&lt;br&gt;
	numberOfFramesWritten = numberOfFramesWritten + 1;&lt;br&gt;
end&lt;br&gt;
progressIndication = sprintf('Wrote %d frames to folder &quot;%s&quot;',&lt;br&gt;
numberOfFramesWritten, outputFolder);&lt;br&gt;
disp(progressIndication);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I'm not sure if you really wanted 1, 15, 30, 45, etc. instead of 1,&lt;br&gt;
16, 31, 46, etc. but I'll just assume you meant what you said.  You'll&lt;br&gt;
need to change the for loop to something like this because of your&lt;br&gt;
strange incrementing (14 for the first one and 15 after that).&lt;br&gt;
for frame = 0 : 15 : numberOfFrames&lt;br&gt;
&amp;nbsp;&amp;nbsp;if frame == 0&lt;br&gt;
	thisFrame = mov(1).cdata;&lt;br&gt;
&amp;nbsp;&amp;nbsp;else&lt;br&gt;
	thisFrame = mov(frame).cdata;&lt;br&gt;
&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
Now, when you subtract, you'll have to cast your frames to int16,&lt;br&gt;
int32, single, or double BEFORE the subtraction, because your&lt;br&gt;
differences could go from -255 to +255 and uint8 will clip any&lt;br&gt;
negative values to 0 so you'll lose them.  You don't have to write out&lt;br&gt;
anything (original frames or subtracted ones) if you don't want to so&lt;br&gt;
you can remove those lines if you want.&lt;br&gt;
Good luck,&lt;br&gt;
ImageAnalyst</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 13:38:03 -0400</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#690647</link>
      <author>Syed Ali</author>
      <description>Dear Sir Image Analyst, &lt;br&gt;
Thanks for your great help, &lt;br&gt;
I will see how I can subtract frames and find out the motion. &lt;br&gt;
I have tried this code to extract all the frames and save it&lt;br&gt;
in jpg format.&lt;br&gt;
&lt;br&gt;
close all;&lt;br&gt;
clc;&lt;br&gt;
&lt;br&gt;
% &lt;br&gt;
fram_test = aviread('Rhinos.avi'); % Read avi test file&lt;br&gt;
for j=1:length(fram_test)    % Loop for creating frames with Name Missile and &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;filename=['Rhinos-', num2str(j) '.jpg']; % save it as jpg&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imwrite(fram_test(j).cdata,filename,'jpeg');&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
But your code is more managed :)&lt;br&gt;
could you please help me in how can I  work with cdata and map&lt;br&gt;
so it will be fast. Cause in my code it will take longer time. As when &lt;br&gt;
the size of file is increased to 816 frames.&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Syed</description>
    </item>
    <item>
      <pubDate>Fri, 30 Oct 2009 16:31:20 -0400</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#691000</link>
      <author>ImageAnalyst</author>
      <description>On Oct 29, 9:38&#160;am, &quot;Syed Ali&quot; &amp;lt;sfaisalal...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Dear Sir Image Analyst,&lt;br&gt;
&amp;gt; Thanks for your great help,&lt;br&gt;
&amp;gt; I will see how I can subtract frames and find out the motion.&lt;br&gt;
&amp;gt; I have tried this code to extract all the frames and save it&lt;br&gt;
&amp;gt; in jpg format.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; close all;&lt;br&gt;
&amp;gt; clc;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; %&lt;br&gt;
&amp;gt; fram_test = aviread('Rhinos.avi'); % Read avi test file&lt;br&gt;
&amp;gt; for j=1:length(fram_test) &#160; &#160;% Loop for creating frames with Name Missile and&lt;br&gt;
&amp;gt; &#160; &#160; &#160; filename=['Rhinos-', num2str(j) '.jpg']; % save it as jpg&lt;br&gt;
&amp;gt; &#160; &#160; &#160; imwrite(fram_test(j).cdata,filename,'jpeg');&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; But your code is more managed :)&lt;br&gt;
&amp;gt; could you please help me in how can I &#160;work with cdata and map&lt;br&gt;
&amp;gt; so it will be fast. Cause in my code it will take longer time. As when&lt;br&gt;
&amp;gt; the size of file is increased to 816 frames.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; Syed&lt;br&gt;
----------------------------------------------------------------------------------------------------------------------&lt;br&gt;
Syed:&lt;br&gt;
The Image Processing Toolbox has a demo on &quot;Detecting Cars in a Video&lt;br&gt;
of Traffic.&quot;&lt;br&gt;
Have you gone through that tutorial?</description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 17:04:07 -0500</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#692113</link>
      <author>Syed Ali</author>
      <description>Yes thanks, I have seen the Rhino and Traffic both tutorials. &lt;br&gt;
&amp;nbsp;I did the frame subtraction and got the results. Now I need&lt;br&gt;
to store the result as Image, can it be possible. &lt;br&gt;
2nd, Reading long movies like I do have 900 frames will take &lt;br&gt;
long time so is it possible that I can store the frames as MAT &lt;br&gt;
file,... Your hint is required.&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 17:36:43 -0500</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#692131</link>
      <author>ImageAnalyst</author>
      <description>On Nov 4, 12:04&#160;pm, &quot;Syed Ali&quot; &amp;lt;sfaisalal...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Yes thanks, I have seen the Rhino and Traffic both tutorials.&lt;br&gt;
&amp;gt; &#160;I did the frame subtraction and got the results. Now I need&lt;br&gt;
&amp;gt; to store the result as Image, can it be possible.&lt;br&gt;
&amp;gt; 2nd, Reading long movies like I do have 900 frames will take&lt;br&gt;
&amp;gt; long time so is it possible that I can store the frames as MAT&lt;br&gt;
&amp;gt; file,... Your hint is required.&lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
------------------------------------------------------------------------------&lt;br&gt;
Yes you can save images as images.&lt;br&gt;
&lt;br&gt;
2nd, Yes you can save any variable in MATLAB to a mat file.  Just use&lt;br&gt;
the save() function.&lt;br&gt;
But I'm not sure why reading 900 frames would take that long, and I&lt;br&gt;
don't know if it would be any faster if you converted it to a mat&lt;br&gt;
file.  I mean 900 frames is around 30 seconds so since you can play it&lt;br&gt;
in a media player program it shouldn't take any longer than 30&lt;br&gt;
seconds.  What kind of hyper speed do you require?  By the way, 900&lt;br&gt;
frames is NOT a long movie.</description>
    </item>
    <item>
      <pubDate>Thu, 05 Nov 2009 03:50:03 -0500</pubDate>
      <title>Re: Need urgent help in video image processing</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264395#692277</link>
      <author>Syed Ali</author>
      <description>Well actually I need to do some operations on Video Frames&lt;br&gt;
and later on I will try to do real time processing so for the learning aspect&lt;br&gt;
the 900 frames will take more time, some of my friends told me that&lt;br&gt;
I can try to store all the segmented frames as jpg and later on &lt;br&gt;
save it as MAT file, as MAT files will take less time.&lt;br&gt;
But again it is a problem that I can read selected frames like &lt;br&gt;
with equal difference of 15 frames I can read the R, G, and B components&lt;br&gt;
of each frame but how can I take them in a movie again. &lt;br&gt;
Like from 900 frames with capturing every 15th frame we can have&lt;br&gt;
60 frames so we start taking difference of these frames and store it &lt;br&gt;
again as a movie to find out how they are working, so there we have&lt;br&gt;
4 movies as outputs&lt;br&gt;
1. Real Avi movie and its difference&lt;br&gt;
2. Only R Component difference movie&lt;br&gt;
3.Only G Component difference movie&lt;br&gt;
4. Only B Component difference movie.&lt;br&gt;
&lt;br&gt;
And how can these be done with MAT file. I try to save it as Mat file&lt;br&gt;
but it gives me error.&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Syed</description>
    </item>
  </channel>
</rss>

