When the traditional CANNY algorithm is applied for edge detection, thresholds are needed to filter candidate edge points after non-maximal suppression. But at present, thresholds are set by experience and the optimal choice is obtained by repeated tests and comparisons. In addition, the choice of current thresholds does not take characteristics of uneven lighting images into account. In some special environments, such as the underground coal-mine, this disadvantage would lead to two adverse aspects, emergence of unreal edges and loss of real edges. Aiming at these problems, this paper analyzed characteristics of uneven lighting image and proposed a novel definition of gradient, non-uniform gradient, based on the nonlinear visual perception characteristic. Then we give an adaptive clustering algorithm for calculating two thresholds based on the minimum intra-class variance theory. The clustering feature of the algorithm is a non-uniform gradient histogram, so that the selection of two thresholds is associated with both gray scale and gradient of the image. Theoretical and experimental results show that the algorithm has the brightness, contrast adaptation and correctness, and conform to the people's perception.