Hyperspectral images are used for anomaly detection; the improvement over broadband imagery is due to the available spectral information, converting a two-dimensional image into a datacube. This paper deals with subpixel point target detection. The RX algorithm provides a statistical metric for how different an examined pixel is from the background in the data cube. It employs an inverse covariance matrix to estimate and limit the effect of the noise, which is normally estimated from all the pixels in the data cube. Since the background is non-stationary, an improvement in the detection performance can be achieved by segmentation. The first objective of this paper is to quantify in the algorithm the effect of using covariance matrices which are derived from the segments or the more local environments in which the pixel can be found. In addition, practically, pixels may be erroneously assigned to a specific segment though they are influenced by neighboring areas. We will examine different methods of choosing the "pure" pixels of each segment, and the influence of these methods on the probability of detection results.