An error compensation method is proposed to improve measurement accuracy of an absolute optical encoder. The proposed method is based on empirical mode decomposition. A novel trend extracting scheme is proposed based on the Hilbert marginal spectrum. The proposed method is superior to the traditional EMD-based method.