An efficient feature extraction algorithm based on optimized Gabor filters and a relative variation analysis approach is proposed for iris recognition. The Gabor filters are optimized by using the particle swarm algorithm to adjust the parameters. Moreover, a sequential scheme is developed to determine the number of filters in the optimal Gabor filter bank. In the preprocessing step, the lower part of the iris image is unwrapped and normalized to a rectangular block that is then decomposed by the optimal Gabor filters. After that, a simple encoding method is adopted to generate a compact iris code. Experimental results show that with a smaller iris code size, the proposed method can produce comparable performance to that of the existing iris recognition systems.