A method to recover the image of an object behind a highly scattering medium with higher accuracy is presented. Instead of the Pearson correlation coefficient (PCC) used in the existing methods, structural similarity (SSIM), which is known as an excellent evaluation indicator of image quality, is employed as the cost function for the wavefront optimization. Compared to PCC, better imaging quality can be acquired with SSIM, because the latter comprehensively analyzes the luminance, the contrast, and the structure of imaging results. By comparing the performances of the three commonly used global optimization algorithms, including a genetic algorithm (GA), particle swarm optimization and differential evolution algorithm, we verify that GA has the best reliability and stability to solve this multidimensional wavefront modulation problem among these global optimization algorithms, including in strong noise environments. This work can improve the quality of imaging through a highly scattering medium with a wavefront optimization technique and can be applied to the fields of optical detection or biomedical imaging.