Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Matlab video processing problem

Status
Not open for further replies.

galardo86

Newbie level 1
Joined
Jun 8, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
Hello

My name is Boris, Recently i start to learning about video processing.
I wrote a simple code in Matlab that convert video file from "RGB" to "Grayscale",
But when i trying to Play converted file by using "implay" function i get errors about last line of the code.

I hope someone can guide me to solve the errors

I use MATLAB 2008b
The Class of the video file is : uint8

Code:
-------------------------------------------------------------------------------------
clc
clear
close all

rgb = 3;
gray = 1;

my_video = mmreader('CIMG1232.avi');
frameRate = get(my_video,'FrameRate');

nframes = get(my_video, 'NumberOfFrames');
I = read(my_video, 1);

video_p = zeros([size(I,1) size(I,2) gray nframes], class(I));

for i = 1 : nframes
singleFrame = rgb2gray(read(my_video, i));
video_p:),:,:,i) = singleFrame;
end;

implay(video_p, frameRate);
----------------------------------------------------------------------------------------

Thanks in advance
 

Hi Boris,

I tried your code in the latest release (R2012a) and it works just fine with the built-in AVI file "rhinos.avi". Not sure what could be causing the problem. Unfortunately, I no longer have 2008b installed to try it out.

You could also view the video in the loop where you convert to grayscale. Use "imshow" with an existing figure window followed by the command "draw now". This doesn't provide the nice controls of implay, but it does show your video.

Thanks,
Bruce Tannenbaum
MathWorks

Hello

My name is Boris, Recently i start to learning about video processing.
I wrote a simple code in Matlab that convert video file from "RGB" to "Grayscale",
But when i trying to Play converted file by using "implay" function i get errors about last line of the code.

I hope someone can guide me to solve the errors

I use MATLAB 2008b
The Class of the video file is : uint8

Code:
-------------------------------------------------------------------------------------
clc
clear
close all

rgb = 3;
gray = 1;

my_video = mmreader('CIMG1232.avi');
frameRate = get(my_video,'FrameRate');

nframes = get(my_video, 'NumberOfFrames');
I = read(my_video, 1);

video_p = zeros([size(I,1) size(I,2) gray nframes], class(I));

for i = 1 : nframes
singleFrame = rgb2gray(read(my_video, i));
video_p:),:,:,i) = singleFrame;
end;

implay(video_p, frameRate);
----------------------------------------------------------------------------------------

Thanks in advance
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top