Hyperspectral imaging is a technique used to collect the same scene with different wavelengths, achieving both high spectral and spatial resolution. Hyperspectral imaging plays an important role in several scenarios involving target detection, among which landmine detection is a very challenging one. In this work, we developed a procedure based on pixel similarity measures to detect rare pixels present in a scene. The method can be combined with most of the existing detection algorithms in order to reduce the complexity and improve the performance. The developed method was tested on various types of hyperspectral images where the spectra of the landmines were simulated in different parts of the scenes with different mixing factors. The performance of the proposed method is also confirmed by tests made in real scenarios. Comparisons with state-of-the-art existing algorithms demonstrate that the method achieves excellent detection performance, with a reasonable computational complexity.