Holographic imaging has the advantages of low noise and simple operation. This kind of technology requires precise control of electromagnetic waves, so as to achieve the desired radiation field. Different from phased arrays, the programmable metasurface is low-cost, low-consumption, and easy to be fabricated. With their potentiality and flexibility, programmable metasurfaces have been introduced into the holographic imaging system. Given the desired radiation characteristic, it is usually challenging to find the corresponding coding matrix of the programmable metasurface. In this paper, the binary particle swam optimization (BPSO) algorithm is used to design the code matrix of 1-bit programmable metasurfaces because of its strong randomness and robustness. Besides, in order to enhance the convergence of the whole algorithm, a local mutation strategy is integrated into the BPSO algorithm. Experimental results show that the proposed BPSO algorithm is superior to the simulated annealing (SA) algorithm in terms of convergence speed and accuracy.