function [capture,fit]=digitize()
filename=input('Filename: ','s');
im=imread(filename);
f=figure;
image(im);
hold on;
numref=3;
cref=zeros(numref,3);
cabs=zeros(numref,3);
for i=1:3
    r=0;
    while ~all(size(r)==[1,2])
        r=input(['Reference Point ',num2str(i),': ']);
    end
    cref(i,:)=[r,1];
    figure(f);
    cabs(i,:)=[ginput(1),1];
end
m=mrdivide(cref',cabs');
numcurves=input('Number of Curves to Digitize: ');
capture=cell(numcurves,1);
fit=cell(numcurves,1);
colors='bgrcmyk';
for i=1:numcurves
    color=colors(mod(i-1,length(colors))+1);
    raw=[];
    pt=0;
    display(['Select points for curve ',num2str(i),' (Press enter when done)']);
    cap=true;
    while cap
        figure(f);
        newpt=ginput(1);
        if isempty(newpt)
            cap=false;
        else
            pt=pt+1;
            raw(pt,:)=newpt;
            if (pt==1)
                p=plot(raw(1,1),raw(1,2),[color,'.']);
            else
                set(p,'xdata',raw(:,1),'ydata',raw(:,2));
            end
        end
    end
    temp=m*[raw,ones(pt,1)]';
    capture{i}=temp(1:2,:)';
    fit{i}=spline(temp(1,:),temp(2,:));
    x=linspace(min(temp(1,:)),max(temp(1,:)),1000);
    y=ppval(fit{i},x);
    temp=m^-1*[x;y;ones(1,1000)];
    plot(temp(1,:),temp(2,:),color);
    set(p,'xdata',[],'ydata',[]);
end