% loadtestpattern.m  loads testpattern
%
% Use: f1=loadtestpattern(100); % converts to grey and loads first test pattern
%    : [r2 g2 b2]=loadframe(101); % loads second test pattern

function [Rc Gc Bc] = loadtestpattern(k); % crops to size of image area

%pixel coords of edges of greyscale test pattern bars determined
%by hand using XV; not exact; probably +/- 3 pixel err
bar_edges_m=[392 571 649 724 910];
bar_edges_n=[495 585 680 776 873 976 1064 1157 1253 1345 1439 1532];

if ((k<100) | (k>118))
  error("loadtestpattern: must be from frame 100 to frame 118")
end%if

if nargin ~=1
  error("loadframe: must have 1 input argument k")
end%if nargin
if nargout~=3
  if nargout ~= 1
    error("loadframe: must have 1 or 3 output arguments (Y or R, G, B)")
  end%if nargout
end%if nargout

if nargout == 3
  [R G B] = loadframe(k);
  Rc = R(395:907,494:1524);
  Rg = G(395:907,494:1524);
  Rb = B(395:907,494:1524);
end%if
if nargout == 1
  R = loadframe(k);
  Rc = R(395:907,494:1524);
end%if

