# Optimal Thresholding for Multi-Window Computed Tomography (CT) to Predict Lung Cancer
## 2 Proposed Method
### Nodule Detection  
After the lungs are segmented, the next step is the extraction of vessels from the lungs. We achieve this by simply applying thresholding to the segmented lungs. The intensity levels of objects inside the lungs are lower than the lung background. We observe that a threshold value \(-500\) is a good choice to extract vessels and nodules from the segmented lungs, as shown in Figure 8a. Following vessel extraction, morphological techniques, namely binary opening and binary closing, are used to eliminate the smaller objects from the area. We calculate the region of all the objects included in the vessel mask. Almost all nodules are circular, with white pixels covering most of the circle. As a result, we can disregard the additional objects with the elongation feature. We compute the diameter of each lesion to detect the nodule. The diameter threshold that we set to detect nodules is 3 mm because, in our dataset, the radiologists annotated the nodules within the range of 3-30 mm and this is the general nodule size in lung cancer. A few radiologists considered a nodule size of 2 mm but they later disregarded these annotations [41]. Figure 8c shows the  
Figure 6: The top two rows show a few examples where the segmentation using the global threshold is successful, and the bottom two rows show some examples where the method fails. In each pair, the left is the test image and the right is the segmentation result.  
nodule detected using the extracted nodule candidates (shown in Figure 8b). Figure 8d shows the detected nodule in the original image. The pseudocode of the proposed algorithm is presented in Algorithm 1.  
Figure 8: (**a**) Segmented lungs, (**b**) extracted nodule, (**c**) nodule mask, (**d**) corresponding original image with nodule highlighted in red circle.  
Figure 7: (**a**) Segmentation results using the global mean as the threshold, (**b**) segmentation results of the same images using the local mean threshold, (**c**) segmentation results after applying the watershed-based refinement.  
```
0: A CT Image \(I\) of size \(M\times N\)
0: Detected nodule(s).
1: Normalize \(I\) to bring the intensity values within range 0-255
2: Suppress noise in \(I\) using Gaussian blur \([G(x,y)=\frac{1}{2\pi\sigma^{2}}e^{-\frac{x^{2}+y^{2}}{2\sigma^{2}}}]\)
3:if \(I\) is a lung window then
4: Compute histogram \(H\) of \(I\)
5: Find the two local minima \(l_{a},l_{b}\) in \(H\)
6:\([\Upsilon_{1},\Upsilon_{2},\Upsilon_{3}]\leftarrow\) multi-Otsu\((I,l_{a},l_{b})\)
7: Threshold \(I\) using \(\tau_{2}\) to separate lungs from rest of the lung window image
8:else {\(I\) is a mediastinal window}
9:\(\mu_{g}=\left[\frac{1}{MN}\sum_{x=1}^{M}\sum_{y=1}^{N}I(x,y)\right]\) {Compute the global mean \(mu_{g}\) of \(I\)}
10: Use \(\mu_{g}\) to roughly separate divide \(I\) into two regions, \(\Omega_{1}\) and \(\Omega_{2}\).
11:\(\mu_{1}=\frac{1}{|\Omega_{1}|}\sum_{x,y}\Omega_{1}(x,y)\) {Compute the local mean \(\mu_{1}\) of the region \(\Omega_{1}\)}
12:\(\mu_{2}=\frac{1}{|\Omega_{2}|}\sum_{x,y}\Omega_{2}(x,y)\) {Compute the local mean \(\mu_{2}\) of the region \(\Omega_{2}\)}
13:\(\tau=\frac{\mu_{1}+l_{2}}{2}\) {The threshold \(\tau\) is then taken as the average of the two local means}
14: Threshold \(I\) using \(\tau\) to separate lungs from rest of the mediastinal window image
15:endif
16: Threshold \(I\) using threshold value \(-500\) {This extracts vessels and nodules from the segmented lungs \(I\).}
17:\(I\)= OPEN(\(I\)) {OPEN is morphological binary open operator.}
18:\(I\)= CLOSE(\(I\)) {CLOSE is morphological binary open operator.}
19: Drop the objects in \(I\) that have the elongation feature, i.e., those that are not circular
20: Compute the diameter \(d\) of each lesion in \(I\)
21:if\(d\geq 3\) mm then
22: Mark the region as nodule
23:else {\(d<3\) mm}
24: Mark the region as non-nodule
25:endif
26: Highlight the nodule regions, if any, using red circles
```  
**Algorithm 1** Proposed Nodule Detection Algorithm