## 8 Segmenting the Liver in Iss  
The process of segmenting the liver in the Iss can be summarized in the following steps:  
**Step 1:** Threshold the Is image using the liver's intensity parameters and remove the skin, abdomen wall, spleen, and any artifact that may appear in the binary image. **Step 2:** Find the liver seed region using gradient transformation, gradient parameters, and the binary image from Step 1. **Step 3:** Apply the region growing algorithm using the liver seed region and the diagonal gradient image to segment the liver in the CT slice initially. **Step 4:** Extend the initial segmented liver until it meets with the actual boundary of the liver. Segmenting the liver starts with thresholding _Iss_ image using the mean (\(M_{i}\)) and the standard deviation (\(S_{i}\)) parameters, as shown in the following formulas:  
\[Issb1=\left\{ \begin{matrix}1\;if|Iss-M_{i}|\leq a1\times S_{i},\\ 0\;else\end{matrix} \right. \tag{1}\]  
\[Issb2=\left\{ \begin{matrix}1\;if|Iss-M_{i}|\leq a2\times S_{i},\\ 0\;else\end{matrix} \right. \tag{2}\]  
In both binary images _Isab1_ and _Isab2_, the liver was segmented, in addition to the other organs and tissues that shared the same gray level intensities with the liver. The component _a2_ was assigned a specific value to ensure that foreground pixels in _Issb2_ are connected, which will help in the process of removing the skin, the abdomen wall, and the spleen correctly. The component a1 was assigned to a value less than _a2_. Thresholding _Iss_ images using Equation (1) helped to reduce the error of segmenting the attached organs and considering them as a part of the liver. The skin was removed from _Issb2_ and the boundary of the abdomen wall was detected and dilated morphologically using a specified structural element. After that, simple logic and operation between the skin-removed version of the _Issb2_ binary image, and the inverse of the dilated abdomen wall boundary binary image, were implemented. After that, a box boundary around the resulting region was created, and the right bottom quarter was removed. This operation helped to remove the spleen and to reduce the processing area since the liver does not exist or appear in that part. Finally, element-wise logic and operation between Issb1 and processed _Issb2_ was implemented to remove the skin, the abdomen wall, and the spleen tissues from _Issb1_. The liver initial region in the _Iss_ image was segmented next. This region was used as the seed for the region growing algorithm. Finding the liver seed region started with applying the Gaussian gradient transformation on _Iss_ to produce three gradient images: horizontal, vertical, and diagonal. The region with the maximum number of foreground pixels in _Issb1_ was selected and multiplied by each one of the gradient images (corresponding elements were multiplied and return the product in the corresponding elements of the output). The resulting images (_Is_1, _Is_s_2, and _Is_s_3) were thresholded after that using the gradient parameters, as shown in the following equation. \[Issg_{k}=\left\{ \begin{matrix}1 if|Iss_{k}-Mg_{k}|\leq a3\times Sg_{k},k=1,2,3\\ 0\;else\end{matrix} \right. \tag{3}\]  
Element-wise logic and operation were applied on the three binary images that resulted from the thresholded operation, followed by a morphological filtering process to produce the liver seed region. The image that contains the liver seed region will be referred to as Ls binary image. Figure 4 shows two samples of the starting CT slices for two subjects and their segmented liver seed results. The third column in Figure 4 shows the boundary of the liver seed region inside _Iss_. Liver seed region pixels in Ls were considered as correct segmented liver, and the boundary of the liver seed region with the diagonal gradient image (elementary-wise multiplied by _Issb1_) was employed as an input to the region growing algorithm. The region growing algorithm was based on creating a 2D matrix (RGM). This matrix consisted of three columns and an unspecified number of rows.