In this paper, we investigated the possibility of using medical differential criteria to determine the level of radiation in X-ray images of the lungs. We developed a new method for automatic determination and calculation the number of visible vertebrae in the pulmonary X-ray images and proposed a system of automatic out-of-distribution detection that can be used together with deep learning-based systems of pulmonary X-ray image analysis, in particular with the task of tuberculosis detection. The proposed method and system were evaluated using three X-ray lung datasets (Montgomery County chest X-ray dataset, Shenzhen chest X-ray dataset and Tuberculosis X-ray TBX11K dataset). We demonstrated that using the proposed system of out-of-distribution detection allows to enhance the tuberculosis classification results up to 1.3% using the same classification model. We also showed that the proposed system allows to automatically train a composite model which considers X-ray radiation level of the image, which is more effective compared to the traditional one-part model.