Algorithms for pre-processing and processing stages of x-ray images