Acquiring images and plotting graphs using Matlab

In summary, the conversation discusses the creation of a Matlab script that takes images and plots a graph of image intensity versus position. The script uses video input objects and sets properties for the application. There is also a mention of a memory issue that can be solved by using a smaller video or increasing the RAM.
  • #1
barnflakes
156
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
  • #2
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.
 

What is Matlab and how is it used for acquiring images and plotting graphs?

Matlab is a programming language and software package commonly used in scientific and engineering fields. It has built-in functions and tools that make it efficient for acquiring images and plotting graphs, allowing for data analysis and visualization.

How do I acquire images in Matlab?

To acquire images in Matlab, you can use the "imread" function to read in an image file. Alternatively, you can use the "VideoReader" function to capture a series of images from a video file or a connected camera. These functions return an image matrix that can be manipulated and plotted.

What types of graphs can be plotted in Matlab?

Matlab offers a wide range of graph types, including line graphs, scatter plots, histograms, bar graphs, and more. You can use the "plot" function to create basic graphs or use specialized functions like "scatter" or "histogram" for more specific types of graphs.

How can I customize the appearance of my graphs in Matlab?

Matlab has many built-in functions to customize the appearance of graphs, such as changing the color, style, and marker type of data points. You can also add labels, titles, and legends to make your graph more informative. Additionally, you can use the "subplot" function to create multiple graphs in one figure.

Can I export my graphs from Matlab for use in other programs?

Yes, you can export your graphs from Matlab in various formats, such as image files (png, jpeg) or vector graphics (pdf, eps). You can also copy and paste your graphs into other programs like Microsoft Word or Excel. Additionally, you can save your entire Matlab workspace, including graphs, as a .mat file for future use.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
126
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top