Home > chronux > fly_track > videoIO > videoIO_2006b > @videoWriter > addframe.m

addframe

PURPOSE ^

WORKED=ADDFRAME(VW)

SYNOPSIS ^

function addframe(vw,img)

DESCRIPTION ^

WORKED=ADDFRAME(VW)
  Writes a video frame.  VW must be a videoWriter object and IMG a 2D
  numeric array with 1 or 3 channels that is autoconverted to a uint8
  image as follows: 

    type    assumed range
    ----    -------------
    uint8   0 to 255
    double  0 to 1
    logical 0 to 1

SEE ALSO
  videoWriter

Copyright (c) 2007 Gerald Dalley
See "MIT.txt" in the installation directory for licensing details (especially
when using this library on GNU/Linux).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function addframe(vw,img)
0002 %WORKED=ADDFRAME(VW)
0003 %  Writes a video frame.  VW must be a videoWriter object and IMG a 2D
0004 %  numeric array with 1 or 3 channels that is autoconverted to a uint8
0005 %  image as follows:
0006 %
0007 %    type    assumed range
0008 %    ----    -------------
0009 %    uint8   0 to 255
0010 %    double  0 to 1
0011 %    logical 0 to 1
0012 %
0013 %SEE ALSO
0014 %  videoWriter
0015 %
0016 %Copyright (c) 2007 Gerald Dalley
0017 %See "MIT.txt" in the installation directory for licensing details (especially
0018 %when using this library on GNU/Linux).
0019 
0020 [h,w,d] = size(img);
0021 
0022 if (isa(img, 'uint8'))
0023   if (h ~= vw.h || w ~= vw.w)
0024     img = uint8(255*imresize(double(img)/255, [vw.h vw.w]));
0025   else
0026     % no changes needed
0027   end
0028   
0029 elseif (isa(img, 'double') || islogical(img))
0030   if (h ~= vw.h || w ~= vw.w)
0031     img = uint8(255*imresize(img, [vw.h vw.w]));
0032   else
0033     img = uint8(255*img);
0034   end
0035   
0036 else
0037   error('Invalid image type.');
0038 end
0039 
0040 if (d == 1)
0041   img = repmat(img, [1 1 3]);
0042 end
0043 
0044 feval(vw.plugin, 'addframe', vw.handle, img);

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005