An adaptive imaging system with a liquid crystal phase modulator having 127 individually addressed hexagonal elements is experimentally studied. The system operation is based on direct optimization of an image quality metric dependent on image plane intensity distribution. For optimization of the image quality metric we applied a modified version of a stochastic perturbation gradient descent algorithm. Experimental results demonstrated the efficiency of the algorithm for high-resolution adaptive wavefront correction in an imaging system. A modification of the algorithm that significantly accelerates algorithm convergence is suggested and studied by numerical simulation.