The automatic exposure algorithms have been successfully used in a variety of imaging platforms. However, most automatic exposure algorithms are not suitable for the application in space due to the complicated space environment, such as dramatically varying temperature and special space background. Additionally, the algorithms must be designed to adapt to the hardware platform with the limited storage capacity and real-time capability. This paper proposes an improved automatic exposure algorithm for the special application scenario in space, which is suitable for the real-time application of space panorama cameras. In this paper, a simulation experiment of the mean-based exposure algorithm is carried out. And the result shows that temperature change and deep dark background in space environment will cause the computation error. So we introduce the iterative calculation and automatic threshold segmentation method to improve the mean-based exposure algorithm. The improved algorithm is implemented using FPGA in standard hardware description language (VHDL), and a test platform to simulating deep space environment is built with a halogen lamp, a whiteboard and a temperature controlled tank in a dark room. The experiment results show that the exposure time almost unchanged when the dark background varies greatly (25% ~ 100%), which verifies that the effect of dark background is removed. And it can be demonstrated that the influence of temperature on the algorithm is decreased, which based on the experiment result that the exposure time decreases with increasing temperature (15°C to 70°C).