title: Converting rgb-video input to grayscale output
body: <p>I would like to convert a video file using rgb2gray on the videoframes, thing is i'm not completely sure how.</p>
  
  <p>I have got this script file, playing the video file using a slider:</p>
  
  <p>%-------------------------------------------------------------------</p>
  
  <pre><code>function frametracking()
  %# read all frames at once
  filename = uigetfile('*.avi');
  vid = VideoReader(filename);
  numImgs = get(vid, 'NumberOfFrames');
  frames = read(vid);
  
  % Make the UI    
  mx = numImgs-1;
  hFig = figure('Menubar','none');
  uicontrol('Style','slider', 'Parent',hFig, ...
      'Callback',@slider_callback, ...
      'Units','pixels', 'Position',[150 0 260 20], ...
      'Value',1, 'Min',1, 'Max',mx, 'SliderStep',[1 10]./mx);
  pB1 = uicontrol(hFig, 'Position',[150 20 130 20], ...
      'Units','pixels', ...
      'String','Select file', ...
      'Callback',@button1_callback);
  pB2 = uicontrol(hFig, 'Position',[280 20 130 20], ...
      'Units','pixels', ...
      'String','Calibrate', ...
      'Callback',@button2_callback);
  eT1 = uicontrol(hFig, 'Style','edit',...
      'Units','pixels',...
      'Position',[490 400 60 20],...
      'CallBack',@edit1_callback,...
      'String','');
  eT2 = uicontrol(hFig, 'Style','edit',...
      'Units','pixels',...
      'Position',[490 370 60 20],...
      'CallBack',@edit2_callback,...
      'String','');
  eT3 = uicontrol(hFig, 'Style','edit',...
      'Units','pixels',...
      'Position',[490 370 60 20],...
      'CallBack',@edit3_callback,...
      'String','');
  hAx = axes('Parent',hFig,'units','pixels',...
      'Position',[80 80 400 400]);
  grayframe = rgb2gray(frames(:,:,:,1));
  hMainImg = imshow(grayframe(:,:,:,1), 'Parent',hAx);
  
  %# callback functions
      function slider_callback(src,~)
          val = round(get(src,'Value'));  %# starting index
          %# update the thumbnails
          for ii = 1 : numel(hMainImg)
              set(hMainImg(ii), 'CData',frames(:,:,:,ii+val-1))
              drawnow
          end
      end
  
      function click_callback(src,~)
          %# update the main image
        %  grayframe = rgb2gray(frames(:,:,:,1));
          set(hMainImg, 'CData',get(src,'CData'));
          drawnow
      end
  
      function button1_callback(src,~)
  
      end
  end
  </code></pre>
  
  <p>%-------------------------------------------------------------------</p>
  
  <p>At line 40 i've added: grayframe = rgb2gray(frames(:,:,:,1));, this makes the first frame gray. How do I make this count for all frames? My goal is to track an object in the videoframe, so I want to convert the frames to binary images aswell, and apply a additional filter like edge detection or something similar. </p>
  
  <p>Thanks in advance</p>