In polarimetric imaging, the uneven illumination could cause the significant spatial intensity fluctuations in the scene, and thus hampers the target detection. In this paper, we propose a method of illumination compensation and contrast optimization for Stokes polarimetric imaging, which allows significantly increasing the performance of target detection under uneven illumination. We show with numerical simulation and real-world experiment that, based on the intensity information contained in the polarization information, the contrast can be effectively enhanced by proper approach, which is of particular importance in practical applications with spatial illumination fluctuations, such as remote sensing.