MATLAB Acquiring images and plotting graphs using Matlab

  • Thread starter barnflakes
  • Start date
I want to create a Matlab script which takes images and plots a graph of image intensity versus position.

Currently created a script like this:

%Create video input object
vid = videoinput('winvideo',1,'RGB24_640x480');


% Set video input object properties for this application.
% Note that example uses both SET method and dot notation method.
vid.TriggerRepeat = Inf;
vid.FramesPerTrigger = 3;
%vid.FrameGrabInterval = 5;
vid.ReturnedColorSpace = 'grayscale';
%vid.TimerPeriod = 1;
triggerconfig(vid, 'manual')
%vid.TimerFcn = 'trigger(vid)';

%preview(vid);

% Set value of a video source object property.
vid_src = getselectedsource(vid);
vid_src.Tag = 'Gaussian Beam';
get(vid_src);

% Create a figure window.
figure;

% Start acquiring frames.
start(vid);


for m=1:20
trigger(vid);
data_test1 = getdata(vid);

data_test3 = data_test1(:,:,1,1)
size_dt3 = size(data_test3)
yvalues = 1:size_dt3(1,1);
xvalues = 1:size_dt3(1,2);

dt3_columns = sum(data_test3,1);
dt3_rows = sum(data_test3,2);

subplot(2,2,1);
plot(xvalues,dt3_columns);
subplot(2,2,2);
plot(yvalues,dt3_rows);

end
stop(vid)

Which isn't working - says something about not having enough memory. Can anyone offer any help please?
 

Wrichik Basu

Gold Member
2018 Award
1,027
882
says something about not having enough memory.
I haven't checked the whole code, but this problem is because your program is taking up so much of memory that your current RAM is insufficient. Either use a small video, or increase your RAM.
 

Want to reply to this thread?

"Acquiring images and plotting graphs using Matlab" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top