Most digital cameras incorporate nonlinear mapping from the amount of light falling onto an imaging sensor to a picture's intensity. However, this nonlinear mapping would cause problems in some linear operations of image processing such as depth-from-defocus (DFD). We address the erroneous effects of the nonlinear response function of a digital still camera in DFD. A spatial-domain DFD technique called S-transform is employed to present the effects of the nonlinear mapping. To enhance DFD performance, we undistort the camera response function. Comparagrams of differently exposed multiple images are employed to estimate the response function. The estimated response function is then fitted to a piecewise linear function. To compare DFD performance, we use four different approaches of the S-transform for automatic focusing of the camera. Compensation of the nonlinear response function enhances AF performance of the camera and estimates blur parameters more accurately.