Experimenting with Deep Neural Networks for X-Ray Image Segmentation

by Sergey KovalevJune 20, 2016
Learn the results of the research, which explored using the Caffe framework and encoder-decoder convolutional neural networks for lung image segmentation.


Deep neural networks present a great interest for the field of medical image segmentation. This article shares the results of the exploratory phase of the research aimed at examining the potential of deep learning methods and encoder-decoder convolutional neural networks for lung image segmentation. The study was conducted by our partners at the Biomedical Image Analysis Department of the United Institute of Informatics Problems, National Academy of Sciences of Belarus.


Training data set

The training data set consisted of 354 chest X-ray images accompanied by the lung masks obtained through manual segmentation. Two different image sources were used:

Examples of the original images and corresponding lung masks are illustrated in the following figure.

examples-xray-image-segmentationExamples of X-rays and corresponding lung masks


Network architecture and training parameters

In the figure below, you can find the neural network architecture that was used during the study.

deep-neural-network-architectureSimplified scheme of encoder-decoder neural network architecture

The network had a typical deep architecture with the following key elements:

  • 26 convolutional layers
  • 25 batch normalization layers
  • 25 ReLU layers
  • 5 upsampling layers

All experiments and testing were performed using the Caffe framework. The input and output network fragments are illustrated in the figure below.


neural-network-elements-bottomThe input (top) and output (bottom) network elements

The neural network was trained on the Nvidia TITAN X graphics processor with 12 GB of GDDR5 memory. The network training parameters were:

  • Batch size: 6
  • Caffe solver: SGD
  • Number of iterations: 5,000
  • Number of epochs: 85

The total time of the neural network training was approximately three hours. During the training stage, the neural network used approximately 11 GB of GPU memory.



As a result, the segmentation accuracy was assessed by comparing the automatically obtained lung areas with the manual version using Dice’s coefficient, which is calculated as shown in the formula below.



  • T is the lung area resulted from manual segmentation and considered as ground truth.
  • S is the area obtained through automatic segmentation using the neural network.

During the testing stage, the average accuracy was estimated as 0.962 (the minimum score value was 0.926 and the maximum score value was 0.974) with the standard deviation of 0.008.

Examples of the best and worst segmentation results are given in the following figures. The red area in the image below presents the results of segmentation using the trained neural network, and the white line shows the ground truth lung mask boundary.

segmentation-results-max-dice-scoreExamples of segmentation results with the maximum Dice score

Similar to the previous image, the red area in the figure below shows the results of segmentation using the trained neural network, and the white line presents the ground truth lung mask boundary.

segmentation-results-min-dice-scoreExamples of segmentation results with the minimum Dice score

The results obtained during this study have demonstrated that encoder-decoder convolutional neural networks can be considered as a promising tool for automatic lung segmentation in large-scale projects. For more details about the conducted research, see Lung Image Segmentation Using Deep Learning Methods and Convolutional Neural Networks.

The described scenario was implemented with the Caffe deep learning framework. If you have tried to use Deeplearning4j, TensorFlow, Theano, or Torch for this purpose, share your experience in the comments.


Further reading


About the author

Sergey Kovalev is a senior software engineer with extensive experience in high-load application development, big data and NoSQL solutions, cloud computing, data warehousing, and machine learning. He has strong expertise in back-end engineering, applying the best approaches to development, architecture design, and scaling. Sergey also has a solid background in various software development practices, such as the Agile methodology, prototyping, patterns, refactoring, and code review. Now, his main interest lies in big data distributed computing and machine learning.

To stay tuned with the latest updates, subscribe to our blog or follow @altoros.