The non-interferometric phase recovery method which is based on the transport of intensity equation is an important phase acquisition technique in microscopy imaging. In the actual operational process of this technology, at least three intensity images are needed to solve the equation. In the image acquisition process, the selection of the focused image is very important, but it is usually determined by subjective methods, thus causing inaccurate positioning of the infocus, which further affects the precision of phase recovery result. A phase recovery algorithm based on edge detection and duty ratio is proposed. Firstly, a series of 'subjectively determined focused images' collected by the microscope are edge-extracted to obtain corresponding edge information points. Then the real in-focus position is found by calculating the duty ratio, and the corresponding defocused images are selected according to the position of the focused image. Finally, the high-precision phase recovery result is obtained by using these images of the accurate position to solve the equation. The algorithm does not require complex operations such as hardware modifications and can be applied to both discrete and continuous sample distributions. The experimental results effectively prove that the algorithm can accurately find the in-focus position, which improves the accuracy of phase recovery compared with the traditional method that is subjectively determined in-focus image position.