## 8 Segmenting the Liver in Iss
The horizontal coordinates, vertical coordinates, and diagonal gradient values for each boundary pixel were stored in a row in RGM. In the beginning, each pixel in Ls was assigned one of three different values: 2 as a liver pixel, 1 as an added pixel to RGM, and 0 as an un-added pixel to RGM. Pixels of the liver in the diagonal gradient image is extracted using the liver seed region, and the mean (Mg) and the standard deviation (Sg) values were calculated. The implementation of the region growing process is presented in Algorithm 1. Thmp was specified a threshold value greater than zero, and Mp was a value initialized to zero at the beginning of the implementation and was updated later. The mini function returns the minimum absolute value of subtracting the diagonal gradient values stored in the 3 rd column of RGM from the Mg value and assigns it to Mp. The mini function returns the index of the minimum absolute value as well. The row in RGM pointed by the index contained the location of a pixel, which will be considered a liver pixel. After that, the eight neighbor pixels of the current liver segmented pixel were tested to check whether each one should be added to the RGM or not. Then, the row that contained the current liver pixel segmented information was removed from RGM. The iteration process was continued in this manner until all the diagonal gradient values stored in RGM were greater than Thmp. Finally, the segmented liver in the Iss using the region growing algorithm was processed using morphological close operation. In some cases, the result of segmenting the liver in _Is_s from the previous step did not reach a satisfactory level. To improve the segmentation result, a new method to extend the segmented liver region until it reaches the actual boundary of the liver was proposed. Each pixel in the boundary of the segmented liver was dilated using a disk structural element. The size of the structural element for each dilated pixel was adaptive and depended on the  
Figure 4: Samples from the liver seed segmentation results. (**a**) Original, (**b**) seed segmented liver, (**c**) boundary of the seed segmented liver. distance between that pixel and the nearest edge pixel in the actual liver within a specific condition. The method is presented as follows:  
**Step 1:** Apply canny edge detection on _Iss_. The resulting binary image will be referred to as CE. **Step 2:** Find the boundary of the initial segmented liver. **Step 3:** Compute the Euclidean distance (ED) using CE. Each pixel is presented by the distance between that pixel and the nearest non-zero pixel of CE and the index of the nearest non-zero pixel of CE. **Step 4:** Locate the coordinates of the segmented liver boundary pixels in EDT using the binary image from Step 2. **Step 5:** Liver boundary pixels that are indexed to the same nearest non-zero pixel of CE are grouped and dilated using a disk structural element. The size of the structural element is equal to the minim distance in the group. **Step 6:** The resulting image is added to the initial segmented liver and morphologically filtered and smoothed. For a better understanding of the proposed method, the following illustration is presented. In Figure 5a, the inner oblong can be considered as the boundary of the initial segmented liver, and the outside edge map can be considered as the results of the canny edge detection operation. In many cases where attached organs are present, the canny edge usually failed to find the edge between the liver and the attached organs. Here, the edge map demonstrates a case where an oblong object is attached to a circular object, and they both share the same gray scales. Figure 6 shows the result of segmenting the liver in _Iss_ for two subjects. To the left, the initial segmentation results are shown, and to the right, the results of applying the proposed enhancement method are shown. At this stage, the liver was completely segmented in Iss. Next, the liver in the previous and subsequent CT slices in the data set of a subject was segmented.