In patients suffering from Parkinson's disease (PD), Deep Brain Stimulation (DBS) neurosurgery is the best alternative to medical treatment. This surgery produces a Volume of Tissue Activated (VTA) whose correct location in the brain depends on the precise position of the DBS electrodes. In this paper, we automatically locate DBS electrodes using a threshold-based medical imaging segmentation methodology, by determining the optimal value of this threshold adaptively. We propose a method for automatic segmentation of the DBS electrodes, which adjusts itself to the intensity and rotation parameters of each CT scan. This method includes the CT image registered with a delimited anatomical atlas, which allows the creation of a Region of Interest (ROI) fully adjustable to the anatomy of each patient. The proposed method allows the localization of DBS electrodes in Computed Tomography (CT) images, with an accuracy of 0.2 mm.