Fingerprint authentication for content protection in the human-machine systems, cybernetics, and computational intelligence is very popular. Because of the complex input contexts, low-quality input fingerprint images always exist with cracks and scars, dry skin, or poor ridges and valley contrast ridges. Usually, fingerprint images are enhanced by one stage in either the spatial or the frequency domain. However, the enhanced performances are not satisfactory because of the complicated ridge structures that are affected by unusual input contexts. In this paper, we propose a novel and effective two-stage enhancement scheme in both the spatial domain and the frequency domain by learning from the underlying images. To remedy the ridge areas and enhance the contrast of the local ridges, we first enhance the fingerprint image in the spatial domain with a spatial ridge-compensation filter by learning from the images. With the help of the first step, the second-stage filter, i.e., a frequency bandpass filter that is separable in the radial- and angular-frequency domains, is employed. It is noted that the parameters of the bandpass filters are learnt from both the original image and the first-stage enhanced image instead of acquiring from the original image solely. It enhances the fingerprint image significantly because of the fast and sharp attenuation of the filter in both the radial and the angular-frequency domains. Experimental results show that our proposed algorithm is able to handle various input image contexts and achieves better results compared with some state-of-the-art algorithms over public databases, and to improve the performances of fingerprint-authentication systems.