© 2015 Society of Photo-Optical Instrumentation Engineers (SPIE). A technique based on a spatial light modulator is proposed for the labeling of nonplanar surfaces. This technique arises from the combination of a general method for generation of digital holograms with a diffractive axilens. Unlike existing methods in which hologram contrast critically decreases out of the focal plane, our proposed approach allows the system to increase the focus depth, resulting in enhanced hologram images out of the focal plane. Two existing methods for hologram generation are theoretically and experimentally compared in terms of efficiency and contrast: the iterative Fourier transform algorithm-based method and the random multiplexing of different lenses method. The most suitable one is selected for the implementation of the new axilensbased technique. Experimental results obtained with the axilens method provide a significant enhancement of the image quality of holograms obtained out of the focal plane when compared with an existing technique. The approach proposed in this manuscript may be of interest in industrial applications, where alphanumeric data must be registered on nonflat surfaces, as in the cases of beverage cans or bottles.