Acquiring images and plotting graphs using Matlab

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 5K views
barnflakes
Messages
156
Reaction score
4
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?
 
on Phys.org
barnflakes said:
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.