Comparative Analysis Between Different Lung Segmentation Techniques

. For the purpose of identifying various lung illnesses, computed tomography (CT) pictures of the lung must be segmented. The most significant aspect of medical imaging is image segmentation. Via an automated process, the ROI (region of interest) is extracted. The process of segmentation separates an image into sections according to a particular interest, such as segmenting human organs or tissue. Several medical disorders can benefit from the segmented image of the lung. We specifically compared and analysed various threshold segmentation algorithms in this paper in an effort to determine which one would be the best to use moving forward with image processing. We have used Computed Tomography (CT) images of Lungs with Tuberculosis (TB) dataset from Kaggle for image processing and compared them with finely masked CT images to infer the best Threshold algorithm. We have decided to do the analysis on Threshold algorithms named as Binary Threshold, Otsu’s Threshold, and Adaptive Threshold. Comparison has been done based on performance parameters such as Accuracy, Precision, Recall Value, f1-score, etc. The results are also represented in Graphical format for better understanding of performed comparison study.


Introduction
Digital image processing has recently assumed a key position in the world of information and computer technologies. It now forms the basis for many other applications, such as computer vision, space exploration, remote sensing, and medical diagnosis, to name a few. Digital images are subjected to a set of techniques collectively referred to as "digital image processing" (DIP) to improve their quality or facilitate information discovery. The DIP is now a somewhat specialized area of computer studies. Over the past 15 years, a growing number of techniques for processing digital images and converting them into different forms have been introduced into medical practice. As in the current work, digital image processing is used to detect TB. Tuberculosis (TB), also known as consumption, is a chronic infectious disease caused by Mycobacterium tuberculosis. This bacterium can attack various organs in the body, although the lungs are often the primary targets. TB is transmitted through the air when an infected person coughs or sneezes, making it highly contagious. If left untreated or undetected, it can be fatal. To diagnose TB, a chest X-ray or sputum sample culture may be used.
According to the World Health Organization, the main ways to contract tuberculosis (TB) and die from it include inhaling airborne droplets, drinking tainted water or food, or coughing or sneezing from an infected individual. One of the top 10 ailments associated with cough is tuberculosis. According to 2015 data, there were 10.4 million new cases of TB, and the disease caused 1.8 million deaths worldwide. Developing countries accounted for nearly 95% of all TB-related fatalities.
Our project focuses on conducting a comparative analysis of various threshold techniques that are commonly used in image processing. Specifically, we aim to evaluate the effectiveness of these techniques in accurately segmenting lungs from chest X-rays. By comparing the results of different threshold techniques, we can determine which method produces the most accurate lung segmentation. After the segmentation, we compare the various threshold techniques used and find out which is the best one using Data Analysis.

Literature survey
Their suggested segmentation algorithm appears to be the best automatic segmentation algorithm for tumors in MRI images, according to the results discussed in a unique approach. Including the suggested enhanced color-based K-Meaning into the framework allows for extremely precise segmentation results. [1] In order to effectively detect lung nodules of any size, a system integrates different image processing approaches. The suggested technique for locating nodules makes use of watershed segmentation and adaptive thresholding. MATLAB is used to actualize these methods and algorithms. For a sample size of 50 instances, the approach had a 96% success rate. [2]. A thorough analysis demonstrating that the suggested approach may produce satisfactory segmentation results in the CT of preschool children has provided a solid basis for the identification of lung illnesses in young children. [3]. Tests of their novel strategy reveal that it successfully detects and segments lung nodules, with a detection accuracy of 100% and an overlap index of 0 for the segmented dice. As a result, the clinical diagnosis of lung cancer can benefit from using this approach as a reference. [4] A novel strategy is presented to enhance lung visibility, and DRLS is used to remove the lungs. Image quality measurements were computed for the threshold findings, and GLCM measures were computed for the extracted lungs, to verify the efficacy of the approach. In the future, clinical chest CT images will be used to verify and evaluate the suggested procedure. [5]. There are various Threshold algorithms implemented beforehand. Our main aim is to study and implement the chosen one Threshold Algorithms by us that are: Adaptive Threshold, Otsu Threshold, and Binary Threshold on CT images of Lungs. Then, performing detailed analysis of it by giving performance parameters as Accuracy, Precision, Recall Value, f1score, etc. The algorithms can be further used by Experts for the required Predictions and Results of TB affected scenarios. scikit-image, etc. 6.

Methodology/Experimental
Software for creating Lung Image Masks: ImageJ

Image Acquisition & Dataset:
There are 138 posterior-anterior radiographs in this collection, 80 of which are normal and 58 of which are abnormal and show signs of tuberculosis. All images are accessible in DICOM format and have been de-identified. The set includes a variety of anomalies, such as miliary patterns and effusions. The data set includes text files with radiological readings.

Pre-processing:
Image preprocessing is a crucial step in image analysis and aims to improve the quality of the image, making it easier to analyze and extract information. One common technique used in preprocessing is noise suppression, which involves spatial domain filtering such as the median filter. This technique is particularly effective in suppressing salt and pepper noise, resulting in a clearer image.

Thresholding:
Image thresholding is a basic segmentation method that involves dividing an image into foreground and background. This technique is used to isolate objects in an image by converting grayscale pixels with intensities below a set threshold to black and those with intensities above the threshold to white. The threshold value is determined based on the image's structural strength.
In some cases, determining the threshold value can be challenging, especially when using limited geographic data. In such cases, the technique is used to segment specific areas of the image, such as lung nodules, by removing excess lung tissue.
Thresholding is a simple segmentation method that creates a binary image based on the intensity values of the input image. The technique uses an intensity threshold parameter, T, to separate the image into two or more-pixel values, depending on the value of T. The resulting binary image is useful in various applications such as object detection and feature extraction.
The value of a pixel at position (i, j) in an image is denoted as p (i, j). Image thresholding, a segmentation method, separates an image into foreground and background by transforming grayscale pixels with intensities above a threshold into white pixels and those below the threshold into black pixels to create a binary image. This method can be applied using either global or local thresholding techniques. Global thresholding splits the image into two based on a fixed threshold value, while local thresholding uses thresholding characteristics determined from the local characteristics of pixels in smaller versions of the image. However, this method has several drawbacks, including the difficulty in selecting an appropriate threshold value, the production of only two classes, and its inapplicability to images with many channels. Additionally, thresholding ignores the spatial aspects of the image and is susceptible to noise and intensity inhomogeneity, which can make segmentation more challenging, particularly when working with magnetic resonance imaging. Histogram warping is a technique that can help overcome these issues. The Threshold Algorithms we implemented are as follows: 1. Adaptive Threshold 2.
Otsu Threshold

Adaptive Threshold
One solution to the issues with traditional thresholding methods is adaptive thresholding, which is a local thresholding technique that adjusts the threshold value for each pixel based on the surrounding pixels. This is done by calculating the weighted average of the pixel's neighboring pixels and subtracting a constant parameter from it. Adaptive thresholding is a more sophisticated approach that produces more accurate segmentation results than traditional thresholding methods.
Adaptive thresholding creates a binary image from a grayscale or color input image by assigning a foreground or background value to each pixel based on whether its intensity value is above or below the threshold. There are two main methods for determining the threshold in adaptive thresholding: the Chow and Kaneko method, which divides the image into overlapping sub images and determines the appropriate threshold for each sub image, and local thresholding, which statistically analyzes the intensity levels of each pixel's surroundings.

How does it Works?
Local thresholding is a simple and fast method that calculates the local threshold based on the median value, the mean of the minimum and maximum values, or the average of the local intensity distribution. The selection of the appropriate statistic for determining the local threshold depends on the characteristics of the image. A neighborhood that is too small may result in a poorly selected threshold, while a neighborhood that is too large may not capture the local variations in illumination.
Compared to the Chow and Kaneko method, local thresholding requires less computation but can still produce satisfactory results in certain cases. Adaptive thresholding is particularly useful for images with varying lighting conditions, such as those caused by illumination gradients or shadows, and can produce more accurate segmentation results than traditional thresholding methods.
A bad threshold is selected if the neighborhood is not big enough to encompass enough fore and background pixels. On the other hand, selecting too big of a zone might go against the notion of roughly homogeneous lighting. Compared to the Chow and Kaneko technique, this method requires less computing but still yields satisfactory results in some cases.

2. Otsu's Threshold:
The Otsu method is a technique used to convert a grayscale image into a binary image, named after its creator, Nobuyuki Otsu, in 1979. It is a basic method for adjusting the local threshold value of an image. The objective of this method is to find the threshold value that minimizes the intra-class variation. The intra-class variance is determined by calculating the weighted sum of variances for the two classes. The equation used to calculate the intraclass variance is as follows: Otsu's method aims to determine the ideal threshold that maximizes the variance between classes or minimizes the variance within a class. This is achieved by computing the weighted sum of variances for the two classes separated by a threshold, where the weights correspond to the probability of each class. In other words, the equation used in Otsu's method shows that minimizing intra-class variance is equivalent to maximizing inter-class variance.
ωi is referring to the class probabilities of the class means μi . Histogram t used to measure such class probabilities. Class probabilities use these equations for computation.
Class average in Otsu method was equated by The equation uses the value x(i) at the center of the Ith histogram bin. Otsu's method can also calculate μ2 and ω2 using the method described in equations 3 and 4. In order to obtain histogram bins greater than t, μ2 and ω2 are determined using the method mentioned above for measuring these parameters.
Otsu's method is an iterative algorithm that assumes an image can be divided into foreground and background pixels. It aims to minimize intra-class variance by finding the threshold value that separates the two classes with the least variation. This approach is based on histogram calculations and probability calculations for each intensity level. The algorithm requires the initial values of μ0 and ω0 and calculates σ2 for all possible thresholds. First, the highest possible threshold value is determined and recorded. Then, the two highest peaks and their respective threshold values are computed and saved. The target threshold value is ultimately acquired by averaging these two threshold values. One issue with Otsu's method is that it assumes a bimodal distribution of the grey level values, which can lead to inaccurate results if the distribution is not bimodal. Additionally, it may be difficult to determine the threshold value when the classes are significantly different.

Binary Threshold:
Binary thresholding is a technique used to create a binary image where all pixels with intensities above (or below) a certain threshold value are set to white (or black), and all other pixels are set to black (or white). This results in a two-dimensional NumPy array of Boolean values (0 for black/off and 1 for white/on). Binary thresholding is often used as an initial step before edge detection or contour finding, or to create masks that select only the regions of interest in an image.

Conclusion
The study compared the performance of Binary, Adaptive, and Otsu thresholding on three different images. We have used Accuracy, precision, recall, and F1-score as evaluation metrics. Adaptive thresholding was found to be the best technique with a mean accuracy of 78.69%, followed by binary inverse thresholding with a mean accuracy of 75.59%. Otsu's thresholding, on the other hand, had the worst accuracy of 61.70%.
The Otsu method works well for some images but not for others, especially those with high variation in pixel intensities. The main advantage of Otsu's thresholding is its simplicity of calculation, but it often produces noisy results where the background is detected as foreground. Adaptive thresholding, on the other hand, can handle changing lighting conditions but is computationally expensive and may not be suitable for real-time applications.
In conclusion, this study provides a useful guide for researchers interested in image segmentation. The study highlights the importance of choosing the appropriate thresholding technique for the image being analyzed and provides insights into the strengths and limitations of different thresholding methods.