function [v,a] = imgFlowSep(img, pts, a)
% function [v,a] = imgFlowSep(img, pts, a)
%
% outputs a vector v of the flows, one for each point.
% generates a if it is not included as input
%
% generate a by:
% [a] = imgseg(img,support);
%
% Daniel A. Spielman, Yale University, Oct 3, 2006

pts = round(pts);

if (nargin < 3),
  [a] = imgseg3(img,1);
end

s = sparse(sum(a));
d = diag(s);

l = d - a;

sz = size(img);

st = zeros(sz(1)*sz(2),1);
st(pts(:,1)*sz(1) + pts(:,2)) = 1;
ind = find(st);

l(ind,:) = 0;
l(ind,ind) = speye(length(ind));

f = amdSolveF(l);

for i = 1:length(pts),
  b = zeros(sz(1)*sz(2),1);
  b(ind(i)) = 1;
  v(:,i) = f(b);
end

