We propose a novel method for correcting the effect of nonuniform illumination on a bi-level image. The proposed method is based on a penalized nonlinear least squares objective function that measures the binariness of an image and the roughness of illumination. Compared with conventional methods, it has the advantages of 1) not suffering from a trivial minimizer, 2) not requiring tuning of design parameters, and 3) effective optimization. In addition, it yields a unique solution since the minimization of the objective function is well-posed. In simulations and experiments, the method showed better accuracy and speed than the conventional entropy-based method.