A modified Hopfield neural network with a novel cost function was presented for detecting wood defects boundary in the image. Different from traditional methods, the boundary detection problem in this paper was formulated as an optimization process that sought the boundary points to minimize a cost function. An initial boundary was estimated by Canny algorithm first. The pixel gray value was described as a neuron state of Hopfield neural network. The state updated till the cost function touches the minimum value. The designed cost function ensured that few neurons were activated except the neurons corresponding to actual boundary points and ensured that the activated neurons are positioned in the points which had greatest change in gray value. The tools of Matlab were used to implement the experiment. The results show that the noises of the image are effectively removed, and our method obtains more noiseless and vivid boundary than those of the traditional methods.