Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Acquiring images and plotting graphs using Matlab

  1. Aug 6, 2010 #1
    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?
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Acquiring images and plotting graphs using Matlab
Loading...