function g = fitGamma(input,intensity,maxPt)

if(~exist('maxI','var') | isempty(maxI))
    maxPt = [max(input(:)), max(intensity(:))];
end

% scale data to 0:1
input = input/maxPt(1);
intensity = intensity/maxPt(2);

g0 = 2.2;

g = lsqcurvefit(@gammaFunc, g0, input(:), intensity(:));
