Detection and outlining of boundaries of organs and tumors in computed tomography (CT) and magnetic resonance imaging (MRI) images are prerequisite in medical applications. A special design Hopfield neural network called the contextual Hopfield neural network (CHNN) is presented for finding the edges of CT and MRI images. Different from the conventional 2-D Hopfield neural networks, the CHNN maps the 2-D Hopfield network at the original image plane. With the direct mapping, the network is capable of incorporating pixels' contextual information into an edge-detecting procedure. As a result, the effect of tiny details and noise will be effectively removed by the CHNN. Furthermore, the problem of satisfying strong constraints can be alleviated and results in a fast converge. Our experimental results show that the CHNN can obtain more appropriate, more continued edge points than Laplacian-based, Marr-Hildreth's, Canny's, wavelet-based, and CHEFNN methods.