The threshold method consists of 3 steps:
1) removal large airways from the lung;
2) lung segmentation;
3) morphological smoothing.
## Reference to official issue
I have solved issue #138, there it was proposed to improve lung segmentation:
## Motivation and Context
The algorithm includs errors in lung segmentation, which often occur at the borders of the lungs, when the contrast between the lung parenchyma and the surrounding tissue is low due to pathologic abnormalities that show up as dense regions. In normal lung anatomy, the shape of the costal lung surface is convex.
When an error occurs at the costal border, the surface is typically not convex anymore.
This problem was fixed with method, which was described in issue #138. Also bronches and trachea were indicated and segmented in this method.
## How Has This Been Tested?
I've tested the algorithm over the cases with nodules and compare output with basic segmentation algorithm.
first_patient = load_scan(INPUT_FOLDER)
first_patient_pixels = get_pixels_hu(first_patient)
lungs, trachea = detection_lung_error(first_patient_pixels)
## Screenshots :
You can see that the algorithm includes pathologies, whereas the ventricle isn't included in lungs area:
Segmented lungs and trachea (bronchi) in frontal projection:
![mesh_applied 3 -min](https://user-images.githubusercontent.com/22271721/33988348-32c6cb0a-e0d5-11e7-8b8a-b7a1cbfac080.gif)