MATLAB Acquiring images and plotting graphs using Matlab

AI Thread Summary
The discussion revolves around a user attempting to create a MATLAB script that captures images and plots graphs of image intensity versus position. The script initializes a video input object and configures it for grayscale image acquisition. However, the user encounters a memory issue, indicated by an error message stating insufficient memory. The suggested solutions include using a smaller video file or upgrading the system's RAM to accommodate the memory demands of the script. The focus is on optimizing memory usage to ensure the script functions correctly without errors.
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?
 
Physics news 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.
 

Similar threads

Back
Top