Fully Automatic Segmentation and Three-Dimensional Reconstruction of the Liver in CT Images.

Automatic segmentation and three-dimensional reconstruction of the liver is important for liver disease diagnosis and surgical treatment. However, the shape of the imaged 2D liver in each CT image changes dramatically across the slices. In all slices, the imaged 2D liver is connected with other organs, and the connected organs also vary across the slices. In many slices, the intensities of the connected organs are the same with that of the liver. All these facts make automatic segmentation of the liver in the CT image an extremely difficult task. In this paper, we propose a heuristic approach to segment the liver automatically based on multiple thresholds. The thresholds are computed based on the slope difference distribution that has been proposed and verified in the previous research. Different organs in the CT image are segmented with the automatically computed thresholds, respectively. Then, different segmentation results are combined to delineate the boundary of the liver robustly. After the boundaries of the 2D liver in all the slices are identified, they are combined to form the 3D shape of the liver with a global energy minimization function. Experimental results verified the effectiveness of all the proposed image processing algorithms in automatic and robust segmentation of the liver in CT images.


Introduction
Liver diseases have become one of the most common causes of deaths in the world. Researchers have focus on the prevention and treatment of liver diseases for many years. In recent years, computed tomography (CT) imaging has been widely used in liver disease diagnosis and surgical treatment because tumors or hepatic lesions could be observed easily from the CT image. For the captured CT images, the liver slices need to be examined in the two dimensions one by one. Consequently, it lacks an overall image of the 3D liver. Furthermore, it takes clinicians considerable time to view all the slices and diagnose the disease or evaluate the liver function based on the information divided and presented in different images. erefore, it is desirable that 2D liver slice is segmented from CT images, and the 3D liver is reconstructed automatically and robustly beforehand. us, the clinicians could get the information of the 3D liver at a glance and diagnose the liver disease or evaluate the liver function more conveniently. is desire has led researchers worldwide to devote themselves to the research of coming up with automatic and robust liver segmentation methods. After so many years of research, it remains an open problem because the liver is adjacent to many other organs, such as the kidneys, spleen, stomach, intestines, and bones. In many cases, the intensity of the liver and that of the adjacent organ is indistinguishable. In addition, the shape of the liver varies according to the individuals. As a result, automatic and robust segmentation of the liver from the CT images remains as one of the most challenging artificial intelligence task for many decades.
After so many years of study and research, quite a few liver segmentation methods have been proposed, though none of them have achieved adequate accuracy so far. Among them, methods based on statistical and probabilistic models became the most popular ones [1][2][3][4]. Yet, such kinds of methods require a large size of training samples, which decreases the segmentation efficiency tremendously. Even if dictionary and sparse coding is used to reduce the redundant information, the segmentation efficiency is still not satisfactory. In recent years, deep learning and convolutional neural network have been used to segment the liver in the CT images, and the reported accuracy appears to be promising [5,6]. Similarly, deep learning or convolutional neural network-based methods rely heavily on the training datasets to yield accurate segmentation results. In other words, the accuracy will not be acceptable if the training datasets are not similar enough to the tested case. In reality, the liver of the patients varies tremendously, and it is thus difficult to acquire a complete training datasets. In such situations, both statistical/probabilistic models-based methods and neural network-based methods might fail completely in identifying the livers of some individuals.
ere are also many other methods that do not rely on training datasets. e popular segmentation methods used in identifying the boundary of the liver in CT images include active contour [7], threshold selection [8], level set [9], and graph cuts [10][11][12]. Since its surrounding tissues and connected organs in different slices are different, one segmentation method or several combined segmentation methods [7][8][9][10][11][12] usually could not segment the liver robustly and fully automatically. Hence, heuristic methods are proposed to segment the liver, its surrounding tissues, and its connected organs as a whole [13][14][15]. For instance, the surrounding tissues are segmented first and then serve as a constraint for the segmentation of the liver. In this way, the surrounding tissues are changed from interference factors to the markers of constraint. us, the liver could be segmented robustly and automatically [16].
In this paper, we also propose a heuristic method based on multiple thresholds selection and morphological operations. With a global threshold, we could robustly segment all the connected organs in each CT slice, such as the ribs, the spine, the heart, the kidney, and the stomach. With another global threshold, we could robustly segment the liver with the logic not operation of the segmentation result of the connected organs. erefore, robust threshold selection becomes a critical step in the proposed method. We utilize the slope difference distribution-based threshold selection (SDDTS) method to calculate multiple thresholds in this research work. e robustness of the slope difference distribution-based threshold selection method and its advantage over state-of-the-art segmentation methods have been verified in our previous studies [17,18]. At first, we calibrate the parameters of the slope difference distributionbased threshold selection method with several typical CT images and then use the calibrated parameters for all the CT slices. After segmentation by the global threshold, the segmentation result is filtered by minimizing the Gibbs energy function [19] to reduce inhomogeneity.
en, morphological operations [20] are used to merge divided parts of the same organ, and the merged organ is used as liver segmentation constraint. Since the intensities of the surrounding tissues and that of the liver might be completely the same, we use centroids of the segmented ribs and the spine to fit a curved line, which is then used to separate the liver and the surrounding tissues. After liver segmentation, its boundary is further refined by spline filtering.

Methods
e proposed method is heuristic, and it contains a series of image processing algorithms that vary depending on the index of the CT slice. e core image processing algorithms include (1) threshold selection based on slope difference distribution [17,18] and image segmentation with the selected threshold; (2) energy minimization of segmentation result to eliminate noise; (3) morphological filtering; (4) morphological merging; and (5) spline filtering. e flowchart of the proposed method is shown in Figure 1. e multiple thresholds are calculated from the inputted 2D CT slice. One threshold is used for liver segmentation, and the other thresholds are used for constraint segmentation. e core image processing algorithms are used during constraint segmentation and computing the boundary of the segmented liver.

reshold Selection.
e slope difference distribution is computed from the histogram of the image, and it reflects the global variation rate of the histogram. With the assumption that the thresholding point between two pixel classes varies greatest, the thresholding point could be computed based on the variation rate of the histogram, i.e., the slope difference distribution. e slope difference distribution is formed by a series of slope difference that is calculated at each sampled point of the smoothed histogram. At each sampled point of the smoothed histogram, N points on its left are selected to fit a line model and N points on its right are selected to fit another line model. e slopes of these two line models are calculated. e left slope is subtracted from the right slope, and the slope difference at this sampled point is obtained. First of all, the histogram of the image needs to be calculated and smoothed as follows.
e grey-scale values of the image are scaled to the interval [1,255], and then the histogram distribution P(x) is calculated as follows: where F i denotes the total number of pixels that equals to i and F j denotes the maximum number of pixels that occurs at j in the interval [1,255]. e histogram distribution, P(x), is then transformed to the frequency domain by the discrete Fourier transform (DFT): Only the low frequencies from 0 to W and the symmetric frequencies from 255 − W to 255 are kept: where W is the bandwidth of the low-pass DFT filter. Its value and the value of N are obtained by parameter calibration [17,18]. In general, there are always optimal values of W and N to yield the optimal threshold. However, it is still challenging to determine the optimal W and N by simple parameter calibration. When the values of W and N are not determined properly, the threshold will be determined inaccurately. e reason we choose the Fourier transform-based filter instead of other popular filters is based on the quantitative evaluation and comparison [19]. We found that the Fourier transformation-based filter outperforms other filters significantly in this conducted research work. Transforming from the frequency domain back to the spatial domain To compute the slope difference, we fit two-line models on both sides of the sampled point. e line model is formulated as follows: where (x i , y i ), i � 1 + N, . . . , 255 − N, is the sampled point on the smoothed histogram distribution and a is the slope of the line model. e coefficient of the line model [a, b] T is computed as follows: B � where B is the design matrix of the least square fitting method and is the input data vector. Moreover, are the N adjacent points at the left side of the point (x i , y i ), and are the N adjacent points at the right side of the point (x i , y i ). e left slope and the right slope, a l and a r at point (x i , y i ), are then obtained from Equation (6). e slope difference at point (x i , y i ) is then computed as follows: e discrete version is denoted as s(i), and its continuous version is denoted as that is named as slope difference distribution. Let the derivative of s(x) equal zero and solve it, the valleys V i , i � 1, 2, . . . , M, with greatest local variations are obtained. e positions where these valleys lie are the thresholds that separate different pixel classes. One fundamental property of the slope difference distribution is that the positions of the valleys change monotonically with the line model fitting parameter N. Hence, the parameter could be calibrated to yield the optimal threshold. After the optimum threshold T is selected, the image is segmented by the following equation: where I is the original image and I b is the binarized image.
(i, j) is the index of the pixel in the image. Since multiple thresholds are needed to segment different organs, Equation (9) is the basic format of segmenting a single object. More conditions need to be added in Equation (9), when several independent segmentation results are combined to segment the liver.

Energy Minimization.
ere are many popular noise reduction methods, e.g., the discrete Fourier transformation-based filter [20] and the wavelet image processing [21]. e noise reduction methods are usually applied beforehand in the preprocessing [20]. Since we did not reduce the noise beforehand, we apply a noise reduction procedure immediately after the segmentation. e noise would cause region inhomogeneity, and this inhomogeneity could be formulated by the Gibbs distribution:  where V c (x) is the potential function associated with clique c. e clique c is defined as a set of sites such that any two elements in the clique are neighbours of each other [19]. L is the total number of pixel classes. V c (x) is defined by the following equation: where β is the constant and 1 is its default value. To reduce the noise in the binarized image, the total energy over the whole image is minimized as follows: where I o is the filtered image with Gibbs energy minimization; u and v are the pixel indexes of the image in the vertical direction and in the horizontal direction, respectively; and U and V are the resolution of the image in the vertical direction and in the horizontal direction, respectively.

Morphological Filtering.
Besides the noise, there are many small binarized blobs that do not belong to the liver or the segmented organ. ese small blobs could not be removed by energy minimization. A popular way to remove these small blobs is to count the areas of all the blobs and remove some of the blobs based on their areas morphologically. However, there are also many situations in which these small blobs are connected with the liver or the segmented organ, which make the removal of them more difficult. To remove all these interference blobs, we propose a morphological filtering method that contains the following steps.
Step 1. Erode the segmentation result I 0 morphologically as follows: where B is the 4-connected structure element with the disk shape and its radius is 1, p is the point in the structuring element B, and z is the translation vector.
Step 2. Repeat Step 1 N F times. e default value of N F is 8.
Step 3. Dilate the segmentation result I 0 morphologically as follows: where B s denotes the symmetric or supplement of B.
Step 4. Repeat Step 3 N F times. In summary, the proposed morphological filtering method removes the small blobs by a repeating morphological erosion process first. en, it restores the eroded liver or other organs by a morphological dilation process with the same repeating times.

Morphological Merging.
On the contrary, there are situations where the segmentation result of the organ specially the stomach is split into different parts. To utilize the segmentation result more effectively, it is required that the split parts are merged into a united one. To unite these split parts, we propose a morphological merging method that contains the following steps.
Step 1. Dilate the segmentation result I 0 morphologically as follows: Step 2. Repeat Step 1 N M times. e default value of N M is 16.
Step 3. Erode the segmentation result I 0 morphologically as follows: Step 4. Repeat Step 3 N M times.
As can be seen, the morphological merging is the opposite process of the morphological filtering. It connects the split parts and merges them into one united one by a repeating morphological dilation process first. en, it restores the dilated organ by a morphological erosion process with the same repeating times.

Spline Filtering.
After the liver is segmented, its boundary B is extracted first. e final smooth boundary B s is computed by minimizing the energy between the extracted boundary B and the fitted polynomial spline by the following equation: where α is the smoothing factor and its default value is 0.5.

Liver Segmentation.
We use a typical CT image as shown in Figure 2(a) to illustrate the proposed segmentation method. First, the thresholds are computed with the slope difference distribution as shown in Figure 2(b). Four thresholds are calculated, and they are shown in Figure 2(b), respectively. e threshold T 1 to segment the spine and ribs is denoted by the green asterisk in the green circle, the threshold T 2 to segment the body is denoted by the blue asterisk in the green circle, the threshold T 3 to segment the stomach is denoted by the red asterisk in the green circle, and the threshold T 4 to segment the liver is denoted by the black asterisk in the green circle. With the threshold T 1 , the spine and the ribs are segmented as follows: where I bones denotes the segmented spine and ribs, and it is shown in Figure 2(c). e centroids of these blobs are   calculated as the means of all the pixels they contain. Based on the computed centroids, the blobs are divided into two classes, the first class of blobs that include the blobs on the left and the second class that includes the blobs on the right and around the center. e blobs in the second class are filtered based on their areas, and only the largest one (the spine) is kept. e centroids of the blobs in the first class and the largest one in the second class are used to fit a secondorder curve I curve by the least squared method (Equations (6-8)) as shown in Figure 2(d). is fitted curve I curve is used to separate the tissues with almost the same intensity from the liver. Figure 2(e) shows the fitted curve I curve overlaying on the original image I. As can be seen, the liver and its neighboring tissue on the bottom are separated successfully.
With the threshold T 2 , the whole body is segmented as follows: where I body denotes the segmented body, and it is shown in Figure 2(f ). Figure 2(g) shows the segmentation result of the body after morphological filtering. As can be seen, all the small blobs are removed successfully. e filtered body is then eroded morphologically (Equations (14)-(16)) by the disk structuring element with the radius of N c . N c is calculated as the average width of the segmented ribs, and it is 16 in this specific example. e eroded body is then subtracted from the filtered part, and the constraint circular part I cir is obtained as shown in Figure 2(h). is constraint circular part is also used to eliminate the surrounding tissues that have the same or similar intensities with that of the liver. e constraint circular part overlaying on the original image is shown in Figure 2(i). As can be seen, it is adjacent to the liver, but almost not covering any liver part.
With the threshold T 3 , the stomach is segmented as follows: where I st denotes the segmented stomach, and it is shown in Figure 2(j). It is then filtered by energy minimization, and the result is shown in Figure 2(k). e filtered result is subtracted by the segmented bones I bones shown in Figure 2(c), and the subtraction result is shown in Figure 2(l). e morphological filtering is applied on the subtraction result, and then, only the parts on the right of the spine are kept as shown in Figure 2(m). e morphological merging is applied on the kept parts, and the merged stomach I stm is shown in Figure 2(n). With the constraint of fitted curve I curve , the circular part I cir , and the merged stomach I stm , the liver is segmented by the threshold T 4 as follows: where I liver denotes the segmented liver, and it is shown in Figure 2(o). It is then filtered by energy minimization, and the filtered result is shown in Figure 3(a). As can be seen, there are still significant interference blobs. Immediately following the energy minimization, the morphological filtering is applied, and the filtering result is shown in Figure 3(b). As can be seen, the interference blobs are reduced significantly, and the left blobs could be removed by the morphological area filtering. e largest blob (the liver) is kept after the morphological area filtering and it is shown in Figure 3(c). e boundary of the segmented liver is extracted and smoothed by spline filtering. Figure 3(d) shows the smoothed liver boundary overlaying on the original image. As can be seen, the extracted boundary matches the liver very well.

2.7.
ree-Dimensional Reconstruction. After the twodimensional livers in all the CT slices are segmented and their boundaries are extracted, each boundary is sampled evenly with the same number of points; i.e., the distance between any two adjacent sampled points on the same boundary is almost the same. e number of the sampling points is chosen as 200 in this study. en, all the sampled points from all the slices are stacked together according to their practical pixel distances during the CT scanning. As a result, the three-dimensional coordinates of all the sampled points are obtained. e index of the sampled points in each slice is aligned with each other in the stacking direction (z direction). en, we get 200 curved lines in the stacking direction, and the number of the points on the curved line equals the stacking number N stack . We resample the curved lines by the following spline interpolation filter:  Journal of Healthcare Engineering where P f denotes the smoothed point and P denotes the original sampled point. α is a smoothing factor and f is the fitted spline function (m � 1, 2, . . . , N stack , n � 1, 2, . . . , 200).

Results and Discussion
Since the shapes of the liver and the surrounding organs also vary significantly in different slices, the number of the pixel classes in different slices varies accordingly. e organ that is adjacent to the liver is not fixed, and it might be the stomach, the kidney, or the heart. We thus define the liver segmentation into three cases depending on its adjacent organ. In the first case, there is only stomach adjacent to the liver. In the second case, there is kidney adjacent to the liver. In the third case, there is heart adjacent to the liver. In different cases, the number of the pixel classes is adjusted automatically based on the detected thresholds by the slope difference distribution. en, the five core image processing algorithms are applied one by one. e optimal values of the input parameters are determined for different cases, respectively. After the optimal parameters are calibrated by trial and analysis, they will be used for segmenting the livers in similar CT datasets. For the CT datasets with significant differences, the input parameters should be recalibrated again. As a result, it might require significant manual intervention to determine the optimal parameters for a specific-type CT dataset before the proposed method is run fully automatically for the whole CT dataset. e average time to process one CT image is 2.39 seconds in MATLAB with the i7-6700 CPU. Some typical liver segmentation results for the first case are shown in Figure 4. Some typical liver segmentation results for the second case are shown in Figure 5. Some typical liver segmentation results for the third case are shown in Figure 6. As can be seen, all the segmentation results are acceptable for clinical usage. With all the segmented two-dimensional liver from different slices, the whole three-dimensional liver is reconstructed by the method described in the above section. Figure 7 shows the reconstructed three-dimensional liver.
We use two public datasets to evaluate the proposed method further. e first public dataset (https://eee.deu.edu. tr/moodle/mod/page/view.php?id�7872) is liver transplantation donor database that provided by Emre Kavur from Dokuz Eylul University with the permission of Dokuz Eylul University Hospital. In this set, there are 20 upper abdominal CT image series that belongs to different patients and six sets are training sets. Only ground truths of the  training sets are provided. Since the proposed method does not require training, we use the provided training sets to evaluate our method.
e computed mean ratios of the volumetric overlap error (VOE), relative volume difference (RVD), average symmetric surface distance (ASD), root mean square symmetric surface distance (RMSD), and maximum symmetric surface distance (MSSD) were 9.6 ± 2.2%, 4.2 ± 2.5%, 1.7 ± 0.9 mm, 2.4 ± 1.1 mm, and 9.2 ± 3.1 mm, respectively. We also show some qualitative results in Figure 8. As can be seen, the automatic identified  boundary of the liver matches the manually identified boundary well. e second public dataset, 3D-IRCADb01 (https://www. ircad.fr/research/3d-ircadb-01/), consists of 20 CT scans with corresponding ground truth provided by IRCAD, the French Research Institute against Digestive Cancer. We show the quantitative comparisons with state-of-the-art methods [22][23][24][25] in Table 1. As can be seen, the comparisons are favorable. e proposed method does not require any work for training as state-of-the-art methods [22][23][24][25] do while the achieved accuracy is similar or better. e accuracy of the proposed method differs significantly across different CT liver datasets because the proposed method is heavily relying on the accuracy of threshold selection. Yet, the optimal accuracy of slope difference-based threshold selection could not be guaranteed currently during unsupervised segmentation. In the near future, we will research on algorithms to make the slope difference-based threshold selection method be capable of always selecting optimal thresholds without supervision.

Conclusions
In this paper, a heuristic approach is proposed to segment the liver in CT images fully automatically. It calculates multiple thresholds simultaneously based on the slope difference distribution and then segment the CT image into different meaningful regions with these automatically calculated thresholds. e liver is segmented robustly with the constraint of the surrounding organs or tissues segmented beforehand. To reduce the noise, Gibbs distribution is utilized to minimize the global energy. A morphological filter is proposed to remove the small interference blobs. A morphological merging method is also proposed to unite the divided parts. Experimental results verified all the proposed image processing algorithms and the proposed approach. Since the proposed approach is very efficient and does not require any training datasets, it is thus very promising for clinical usage.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that there are no conflicts of interest.