An algorithm for estimating the optimal regularization parameter by the L-curve