Acquiring images and plotting graphs using Matlab

Click For Summary
SUMMARY

The discussion focuses on creating a Matlab script to acquire images and plot graphs of image intensity versus position using the 'videoinput' function. The user encountered a memory issue while running the script, which captures frames from a video input object configured for RGB24 format. The solution suggested involves either using a smaller video or increasing the system's RAM to resolve the insufficient memory error.

PREREQUISITES
  • Familiarity with Matlab scripting and syntax
  • Understanding of video input objects in Matlab
  • Knowledge of image processing concepts
  • Basic experience with plotting functions in Matlab
NEXT STEPS
  • Explore Matlab's 'videoinput' documentation for advanced configurations
  • Learn about memory management techniques in Matlab
  • Investigate image processing functions in Matlab for optimization
  • Research methods to reduce video file size or resolution in Matlab
USEFUL FOR

Matlab users, image processing enthusiasts, and developers working on projects involving video data acquisition and analysis.

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

  • · Replies 5 ·
Replies
5
Views
3K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K