Automatic Liver Segmentation from 2D CT Images Using an Approximate Contour Model

Due to its precision, computed tomography (CT) is now generally used to image the liver and diagnose its diseases. Computer-assisted methods aimed at facilitating the extraction of organ shapes from medical images and helping to diagnose disease entities are rapidly developing. This study presents a new method of automatically segmenting the shape of the liver, both for cases free of lesions and those showing certain disease units, i.e. focused lesions like hemangiomas and hepatomas. For the 1,330 2D CT images of the abdominal cavity and liver analysed, the Dices similarity coefficient amounted to 81.3 %. The method proposed is to be used in an IT system supporting liver diagnostics.


Introduction
Extracting the shape of the liver from a computed tomography image represents an important step in software supporting medical diagnostics, as it allows superfluous information which is immaterial in the diagnostic process to be eliminated.The automatic extraction of the liver contour and, as a result, segmenting this organ is rather complex due to the presence of other organs found right next to it: Fig. 1.
CT images, the shapes of the liver are highly varied, inter alia due to the individual traits of patients.Computed tomography imaging of the liver can be executed in various M. Ciecholewski ( ) Faculty of Mathematics and Computer Science, Institute of Computer Science, Jagiellonian University, ul.Łojasiewicza 6, 30-348 Kraków, Poland e-mail: marcin.ciecholewski@ii.uj.edu.plphases, namely: parenchymatous, arterial and venous, and this has a major impact on the amount of information found in the image.Computed tomography images can also portray disease units which make extracting the contour difficult.
The liver is quite frequently segmented from CT images.Bae [1] has applied such image processing techniques as thresholding for specified values of grey levels and a method of image smoothing using Gaussian filtration, and has also used specific mathematical morphological operators and Bsplines.Chen [5] proposed combining the FBM (Fractional Brownian Motion) technique with a parameterised active contour method to determine the approximated liver contour, while Ballerini [2] presented an active contour method using genetic algorithms.Publications [2,5] describe a technique consisting in detecting the liver contour before extracting it from the image (DBE-Detect Before Extract).The authors of publication [21] first segmented the lumbar section of the spine, and then determined the borders of regions of interest (ROI) in which the liver shape is found.The lumbar spine section is segmented using thresholding for specified grey-levels of the image and also employing a histogram transformation.Later in the segmentation process, iterative binary morphological transformations like dilatation and erosion are executed.In article [13], neural networks were used to determine the features of an image corresponding to the area occupied by the liver.In article [18], in turn, some varieties of region growing were employed to segment the liver shape from CT images.Another approach is a threshold segmentation, combined with morphological image processing and the use of active contour methods to extract the initial contour, and then segment the liver shape for subsequent CT slices [14].
Many interesting methods and algorithms presented during "MICCAI 2007 Grand Challenge" workshop [11] and Figure 1 CT image of the abdominal cavity.Description of the anatomical situation (figure previously presented in [6]).also after its end, some of them are available through the website [10].In general, interactive methods achieved higher average scores than automatic approaches and featured a better consistency of segmentation quality during this workshop.The three best-rated automatic approaches are all based on statistical shape models with some form of additional deformation [12,15,20].The three best ranked interactive method was based on: -graph-cut and interactive refinement [4] -region-growing and interactive refinement [3] -two-dimensional level sets with transversal contour initialization [9] Currently, semi-automated method using radial basis functions and level sets is the best ranked [23].The first stage of this method is the manual delineation of cross-sections of the anatomical structure in 2-D multi-planar reconstruction views.From this set of contours, an initial 3-D surface is reconstructed using radial basis functions.In the second stage, this surface is automatically evolved under the level set framework using a combination of both image and shape information.Organizers of the competition [11] proposed open source toolkit ITK/SNAP and one ITK/Metal0 graphic format of the shared database containing CT liver images.This allows researchers to compare their results and utilize the experience of previously proposed methods in the same environment.On the other hand, ITK / SNAP does not read common graphic formats, such as tiff, jpg and this is a certain limitation.Software which is developing during this research project is implemented in C# and works on Windows 7/8 platform.CT images are analyzed in common graphic formats such as DICOM, tiff, jpg, etc.In order to compare results obtained by participants of the SLIVER07 competition [10] with results presented here efficient module which converts images from ITK/Metal0 format to common graphic formats will be needed.
In this publication, automatic segmentation was executed in such a way that first the liver contour was found, made up of a finite number of connected polylines approximating individual fragments of the liver edge in the computed tomography image.Then, the image area outside the liver contour was split into two polygons and eliminated from the image.The initial seed point during the calculations was the lumbar section of the spine, which is the central point of every CT image of the liver.The method of determining the approximate contour of the liver within CT images proposed here makes it possible to extract the liver shape both for cases free of lesions and for those exhibiting specific disease units, regardless of their number and location within the liver shape.
This article is structured as follows.Section 2 presents methods of determining the approximate liver contour.Section 3 describes the method of automatically segmenting the liver shape from computed tomography images.The next section discusses the experiments conducted and the research results.The last section contains a summary and sets out directions of future research.

Determining the Liver Contour in a CT Image
This section presents a method of automatically approximating the edge of the liver in CT images, consisting in determining the liver contour before segmenting its shape from the image.The approximate liver contour traced is used in the procedure of segmenting the shape of this organ from CT images (Fig. 2).The method proposed in this section makes it possible to determine the contour both for cases free of lesions and those showing certain disease units, i.e. focused lesions like those presented in Fig. 3b and c.
Radiology images of the liver do not always show a regular shape with a clearly distinguished edge of this organ.Fig. 3c-f show an example liver image with an irregular edge.The contour determining algorithm should enable the edge to be approximated and its regular shape to be obtained.The active contour method in its original form, presented in publications [7,8,16], does not make it possible to eliminate situations like those shown in Fig. 3f.
An additional element of the image which must be considered when finding the edge are ribs, visible in item G of Fig. 1.During the determination of the approximate contour, coordinates which are between the ribs must be found, as shown in examples from images in Fig. 3a-d.
The overview of the proposed method is presented in a diagram in Fig. 2. At the first stage the starting point P ST is found, making it possible to begin determining the left-hand side contour L and the right-hand side contour R of the liver.

Liver Contour Description
In order to describe the liver contour, a specific mathematical model was defined.It represents a certain class of closed figures-polygons-which can be formed using a finite number of component polylines joined together.Formal definitions are presented in Section 2.2.
To describe the liver contour, an assumption was made that every component polyline approximates a specific fragment of the liver edge in the CT image.This assumption was made because the liver edge is irregular on CT images and there are no unanimously defined models of the shape.An example model of component polylines approximating individual fragments of the liver edge in an example CT image is shown in Fig. 4c.The approximate liver contour is built in the following way: beginning with the P ST starting point, interconnected component polylines L s (s = 1 . . .6), are built one after another, as shown in Fig. 4b.These components will describe the contour of the left lobe and the front edges of the liver.After the last polyline L s is formed, component polylines R t (s = 1 . . .6) describing the right-hand side contour of the liver are build.When building polylines R t , the starting point is also the P ST .As the L s polylines approximate a longer fragment of the liver edge than polylines R t , it was assumed that there are at least five L s (maximum 6) component polylines while there are at least two (maximum 3) R t .Figure 4a shows an example CT image of the abdominal cavity and the liver.Figure 4b is the model of a liver contour drawn using L s and R t polylines with the direction in which they were built marked.Figure 4c is the approximate contour of the liver.The location of the starting point P ST determines the split of component polylines into L s and R t , and as a result, the order of building them.The coordinates of the point P ST are calculated automatically.The method of determining the coordinates of the starting point P ST is presented in Section 2.3.

The Mathematical Model of the Liver Contour
The purpose of this section is to present the mathematic model of the liver contour searched for.Definitions and properties of the polylines making up the approximate liver contour in CT images can be written as follows: Let s = 1 . . .6 and j ∈ {0, 1}.The polyline [19] is understood as the set L j s having the form of Where P i P i+1 is a section with the starting point P i and the end point P i+1 .The product P i P i+1 ∩ P i+1 P i+2 is a single-point set containing the end of the section P i P i+1 and the beginning of the section P i+1 P i+2 .The product P i P i+1 ∩ P k P k+1 is empty for k > i + 1.For j = 0 the set L 0 s is empty, while for j = 1, the set L 1 s is not empty.
Let L be a polyline consisting of at least five component polylines L j s , i.e.
Every component polyline L j s approximates a specific fragment of the liver edge in the CT image.The value of the variable j determines whether the next component polyline will be created.In Fig. 5b, if s = 6, this yields value of j = 1.Thus the polyline L 1  6 is the last component approximating the final fragment of the liver edge, while in Fig. 5d the last component polyline is L 1 5 .In the example from Fig. 5d, for s = 6, so we get j = 0, as there is no fragment of the edge which should be approximated with the polyline L 1  6 .Conditions making it possible to check whether the L 1   6   polyline should be built are defined in Section 2.3 (at stage 4 of the presented algorithm for detecting the approximate liver contour).Let t = 1 . . .6 and j ∈ {0, 1}.A set in the form R j t = T i=0 P i P i+1 , also representing a polyline, is given.For j = 0 the set R 0 t is empty, while for j = 1 the set R 1 t is not.Let R be a polyline composed of component polylines The set R is made up of at least two and maximum three joined polylines.In the example from Fig. 5b and d, the component R 1  3 is the last polyline.In the example from Fig. 5d, the polyline R is made up of two component polylines R 1  1 and R 1 3 , so for t = 2, 4, 5, 6 we have R 0 t .The conditions making it possible to determine which polylines are to be build and in what order are presented in Section 2.3 (at stage 5 of the represented algorithm for detecting the approximate liver contour).Fig. 5a, c and e show example CT images of the abdominal cavity containing the liver shape, while Fig. 5b, d and f present the corresponding models of contours drawn using polylines L and R. In Fig. 5b  and f, the polyline L is made up of six joined component polylines, and the polyline of three.In Fig. 5d, the polyline L is represented by five joined component polylines, and R by two.The point P ST is the common starting point of polylines L and R.

The Algorithm for Liver Contour Detection
This section presents the algorithm for automatically detecting the liver contour.The first step in the operation of this algorithm is to find the starting point P ST , making it possible to begin determining the coordinates of polylines L and R which approximate the liver contour.Then, the following stages of the method which allow the polylines L and R to be built are presented.

Stage 1. Finding the starting point P ST
Let the mapping g : M 2 → Z be the grey CT image containing the shape of the liver and The set Z represents integers from the [0, 2 B − 1] interval, whereas B is the number of bits for representing a single pixel.Assuming that a single pixel is represented by one byte, we get Z = {g : g(x, y) ∈ [0, 255]}.
Images with the size of 512 × 512 were considered in the calculations.So we can assume that M = 512.
Finding the starting point P ST makes it possible to launch the algorithm for detecting the approximate contour of the liver.This point is identified in two stages (Fig. 6b): -The Point P SP lying on the edge of the spine is found.
-The point P SP is projected along the X axis to the edge of the liver, thus marking the point looked for: P ST The input position allowing the point P SP to be determined is the middle of the axis of symmetry of the computed In the second situation, the coordinates of the point lying above the lumbar spine section should be found, Fig. 6d.
The procedure of finding the coordinates of the starting point situated above the lumbar spine section is as follows: where M × M is the image size (Calculating the coordinates of the starting point-the centre of symmetry of the image (Fig. 6a and c)) Step 2 Read the value of the grey level g of the pixel with the coordinates (x, y).Execute one of the two conditional instructions: -If g(x, y) ∈ G SP , then decrease the y coordinate by a constant D, until the grey level value not belonging to the set G SP is obtained, i.e. g(x, y) / ∈ G SP -Fig.6d (It was assumed that the G SP set of integers defining grey levels of pixels of the lumbar spine section has the form Z = {g : g(x, y) ∈ [190, 255]}, values from this interval were established experimentally) -If g(x, y) / ∈ G SP , assume x 0 = x, y 0 = y and p 0 = (x 0 , y 0 ) and end the procedure.
In Fig. 6d, the starting point p 0 = (x 0 , y 0 ) situated above the lumbar spine section was obtained in the third iteration.The best results were achieved assuming D = M/34 = 15 pixels.
If we already have the point p 0 = (x 0 , y 0 ) situated above the lumbar spine section, the eventuality should be considered that the aorta is very close to the spine, Fig. 6b.Its location may hinder determining the point on the edge of the spine, i.e.P SP .Consequently, it was assumed that three points p i+1 (i = 0, 1, 2), with the coordinates: should be used for calculations.After projecting points p i+1 to the edge of the lumbar spine section, the distances between them (along the Y axis) are compared and used to determine the coordinates of the point P SP = (xP SP , yP SP ), Fig. 6b.Then, the point P SP is projected along the X axis to the edge of the liver, yielding the coordinates of the starting point P ST , which makes it possible to start identifying coordinates of polylines approximating the liver edge.Below, the procedure of finding the coordinates of the point P SP on the edge of the lumbar section is detailed.

Procedure Find P SP
Step 1 Projecting three points p i+1 (i = 0, 1, 2) along the Y axis to the edge of the lumbar spine section (Fig. 7b).
For every point ) add one to the y coordinate value until one of the following two conditions is satisfied: tion whether the coordinates of the point are on the edge of the lumbar spine section) 2. If y i − y 0 > H (The defined height has been exceeded. The point did not end up on the edge of the lumbar spine) Step 2 Computing the distance along the Y axis between the three points found in Step 2. Example distances are marked in Fig. 7c.Calculate: Step 3 Comparing the distances computed in step 2 and finding the coordinates of point P SP = (xP SP , yP SP ).An example point calculated in step 3 is shown in Fig. 7d. - Notes: Calculations made for a series of 1,330 CT images led to finding that the distance between subsequent points p i+1 (i = 0, 1, 2) along the X axis is D = M/34 = 15 pixels, while the distance along the Y axis from the starting point cannot be greater than the value determined by the constant H = M/15 = 70 pixels.These values were used in test examinations.

Stage 2. Building Polylines Belonging to the Set L
Let P u−1 P u ∈ L i (u ≥ 1) be any section of polyline L i for i = 1 . . .6, and let points P u−1 and P u have the following coordinates: P u−1 = (xP u−1 , yP u−1 ), P u = (xP u , yP u ).The following inequality applies to the coordinates of polylines This example is shown in Fig. 8c.The most precise approximation of the liver contour and the smallest number of arithmetic operations for determining the coordinates of polylines were achieved for dy = 10.In the case of the polyline L 6 (Fig. 8d) the most precise approximation was obtained under the assumption that the distance between subsequent pixels along the Y axis is no greater than 5.For any polyline L i ∈ {L 1 , L 3 , L 4 }, the distance DY along the Y axis between its beginning and end points is the total of elementary distances dy between neighbouring pixels, as shown in Fig. 8c and d.
If L i ∈ {L 2 , L 5 }, then for any section P u−1 P u ∈ L i (u ≥ 1) of these polylines the inequality 0 <| xP u−1 − xP u |≤ dx is satisfied.Just as in the dy case, the best results were achieved for dy = 10.Defining DX as the distance between the start and end points of any polyline L i ∈ {L 2 , L 5 }, it can be assumed that DX is the total of component distances dx between adjacent pixels.
In accordance with formula (3), the polyline L is made up of five joined component polylines.The sixth polyline is added if one of the boundary conditions presented at stage 4 of this method is satisfied during the finding of polyline L 5 points.
To enable the definition of sets of points allowing the approximate liver contour to be found and to undertake the appropriate arithmetic operations to find the coordinates of the approximate contour, the following ranges of grey levels were adopted: G 1 , G 1 , G 2 , G 2 , where: -G 1 = {g ∈ Z : g ∈ (0, 50]} -Fig.9d,  -G    Pixels belonging to the appropriate sets made up of defined grey levels were marked with the same colour in the example shown in Fig. 9c-g.The values of constants defining ends of intervals for sets of points G 1 , G 1 , G 2 , G 2 , were adopted based on the trials conducted on a set of 1,330 CT images of the liver.The existence of still other numerical dependencies is not ruled out, but values proposed in the above way made it possible to achieve the best results.

Stage 3. Finding Points of the Polyline L 1
Figure 10 is a diagram containing all the arithmetic operations needed to find the approximate boundary coordinates of the polyline L 1 .Beginning from the set A 1 which represents gray-level values equal to zero (it means dark background) coordinates are classified to appropriate sets and next moved, according to defined arithmetic operations.If a point belongs to the set A 1 but doesn't belong to the set A 0 (it means that defined boundary condition is not satisfied) then it can be moved further under the condition that its current position is not exceeding the constant value dl x (measured up from its initial position).If the starting point is not located in the area of the dark background (its grey-level value is greater than zero) then classification to the next set--C 1 will be checked.Higher gray-level values are considered in the set C 1 (from the interval (50, 255]).The subsequent set D 1 contains gray-level values from the interval (100, 255].In order to find the approximate liver boundary in a CT image point belonging to the set C 1 or D 1 is moved from an area with high gray level values (i.e.(50, 255]) to the area with lower values of gray-levels (i.e.(0, 50]).Certain estimates of distances of coordinates between calculated points are also very important for evenly approximation of the liver contour.In order to estimate a liver contour it is also considered an opposite situation where the point can be moved from an area with low gray level values to the area where significantly higher values of gray-levels are present.This situation is described in definition of sets E 1 , F 1 and E 0 , F 0 respectively.Moreover, it is also presented in the example below.
As mentioned before, the point P ST = (xP ST , yP ST ) is the starting point from which the subsequent coordinates defining the liver contour are determined.The identification of the point P ST was presented at stage 1 of the procedure of describing the approximate liver contour.Thus we have P ST = P 0 = (xP 0 , yP 0 ), Fig. 11b.The next point of the polyline has the initial coordinates x 0 = xP 0 and y 0 = yP 0 + dy, Fig. 11c.Then, the value of its grey level g(x 0 , y 0 ) (from the interval [0, 255]) is read, Fig. 11d.This forms the basis for classifying it to one of the defined sets of points according to the established constant intervals of grey levels (all sets of points including the conditions describing them are presented in detail further in this stage of the method).For the example from Fig. 11d, the value g(x 0 , y 0 ) = 33.Thus the pixel (x 0 , y 0 ) belongs to two grey level intervals: g(x 0 , y 0 ) ∈ G 1 and g(x 0 , y 0 ) ∈ G 2 .Two adjacent pixels with the coordinates (x 0 , y 0 ) and (x 0 −1, y 0 ) have grey levels from the interval (0, 50].This is one of the defined conditions for the set of points, which enables an edge pixel to be found.Namely: Consequently, an arithmetic operation to reduce the coordinate x is executed, and afterwards the boundary condition defined in the following set E 0 = {(x, y) : g(x, y) ∈ G 1 } is checked.This condition means that the grey level of a point with the coordinates (x, y) no longer falls within the interval (0, 50], but within the interval (50, 255], Fig. 9e.The boundary condition defined in the set E 0 is met only after the third step, i.e. after the coordinate x is reduced three times.Thus we obtain the second coordinate P 1 of the polyline L 1 , Fig. 11e.The next point of the polyline has the initial coordinates x 0 = xP 1 and y 0 = yP 1 +dy.The grey level value g(x 0 , y 0 ) is read for this point, too, and then it is classified to one of the defined sets of point detailed below in this stage of the method.Afterwards, arithmetic operations are executed on its coordinates to find the edge pixel.
The actions associated with determining the initial coordinates can be presented in the following way: Let P u P u−1 ∈ L 1 for u ≥ 1 be any section of the polyline L 1 with the coordinates P u−1 = (xP u−1 , yP u−1 ) and P u = (xP u , yP u ).Let (x 0 , y 0 ) be the initial coordinates of the pixel P u .The following relationship exists: x 0 = xP u−1 , y 0 = yP u−1 + dy.An assumption was made that DY ≤ DY L 1 for DY L 1 = M/6 .
Certain estimates of distances of coordinates along the X axis are important for correctly defining sets which make it possible to classify pixels and undertake the appropriate arithmetic operations to find subsequent edge coordinates.Distances along the X axis between the current location of the point with the coordinates (x, y) and its initial location with the coordinates (x 0 , y 0 ) as well as the distance between the last and the penultimate point of the polyline L 1 i.e. x 1 − x 0 are marked in Fig. 11f, see Fig. 11.The constant dl x denotes the maximum distance along the X axis between the point in its initial and final position.

Sets of Points Allowing Pixels to be Classified to Determine Polyline L 1 Coordinates
Certain sets were defined to make it possible to classify subsequent pixels in order to determine the points of the polyline L 1 .The pixel under consideration is classified to one of the defined sets of points based on: -the grey level value read for its current position, i.e.
g(x, y) -the distance along the X axis between the current location of the point with the coordinates (x, y) and its initial position with the coordinates (x 0 , y 0 ) -the distance along the X axis between the two last points of the polyline L 1 with the coordinates: (x 0 , y 0 ) and (x 1 , y 1 ) Sets of points were defined using image algebra notation [19].After the right classification, the appropriate arithmetic operations detailed in Fig. 10 are executed.

Definition of the set
One of the following two conditions is met: 1.The pixel with the coordinates (x, y) has the value of g = 0 and the distance of its coordinate x from the initial position x 0 does not exceed the constant value dl x (the most precise results were obtained for dl x = 15 and also dl y = 15).2. The pixel with the coordinates (x, y) has the value of g = 0 and the adjacent pixel with the coordinates (x − 1, y) has the value g equal to 0. In addition, the distance of the x coordinate from the initial position x 0 does not exceed the constant value dl x .

Definition of the set
This is the set in which the boundary condition for stopping the execution of arithmetic operations for pixels belonging to the set A 1 is defined.The pixel with the coordinates (x, y) has the value of g = 0 whereas the adjacent one with the coordinates (x + 1, y) has the value g equal to 0.

Definition of the set B
The pixel with the coordinates (x, y) has the value of g = 0 and the distance of its coordinate x from the initial position x 0 is equal to the constant value dl x .

Definition of the set B
This is the set in which the boundary condition for stopping the execution of arithmetic operations for pixels belonging to the set B 1 is defined.The pixel with the coordinates (x, y) has the value of g = and the distance of its coordinate X from the initial position x 0 is equal to the constant value dl x .

Definition of the set C
The point with the coordinates (x, y) has the g value from the interval specified by the set G 1 .In addition, the distance of the initial coordinate x 0 from x does not exceed the constant value of dl x , while the distance along the X axis of the two last pixels of the polyline L 1 is shorter than the constant 1/3 • dl x .

Definition of the set C
This is the set in which the boundary condition for stopping the execution of arithmetic operations for pixels belonging to the set C 1 is defined.The pixel with the coordinates (x, y) has the g value from the interval specified by the set G 1 .

Definition of the set
One of the following two conditions is met: 1.The difference between the constant DY L 1 and DY (DY -the total of component distances dy between points of polylines created so far) is smaller than or equal to the value of 1/2 • DY L 1 .In addition, the estimation between the values of x coordinates of the last two points of the polyline L 1 is satisfied.2. The difference between the constants DY L 1 and DY is smaller than or equal to the value 1/4 • DY L 1 .

Definition of the set D
The pixel with the coordinates (x, y) has the grey level value g from the interval specified by the set G 2 .In addition, two estimations of distances relative to the X axis are satisfied for two pairs of coordinates: 1.The initial value x 0 and x 1 (i.e. for the one but last coordinate of the polyline L 1 ).2. The current value of x and the initial of x 0 .

Definition of the set D
This is the set in which the boundary condition for stopping the execution of arithmetic operations for pixels belonging to the set D 1 is defined.The pixel with the coordinates (x, y) has the grey level value g from the interval specified by the set G 2 .

Definition of the set E
Two adjacent pixels with the coordinates (x, y) and (x − 1, y) have grey level values from the interval specified by the set G 1 .

Definition of the set E
This is the set in which the boundary condition for stopping the execution of arithmetic operations for pixels belonging to the set E 1 is defined.The pixel with the coordinates (x, y) has the grey level value g from the interval specified by the set G 1 .

Definition of the set
The pixel with the coordinates (x, y) has the grey level value g from the interval specified by the set G 1 , while the pixel with the coordinates (x − 1, y) has the grey level value g from the interval specified by the set G 1 .

Definition of the set
This is the set in which the boundary condition for stopping the execution of arithmetic operations for pixels belonging to the set F 1 .The pixel with the coordinates (x, y) has the grey level value g from the interval specified by the set G 1 .

Stage 4. Finding points of subsequent polylines L
The coordinates belonging to subsequent polylines L i : {i = 2 . . .5} are found in the way shown in Stage 3 of this method for the polyline L 1 .Based on the sets of points defined according to pre-set, constant intervals of grey levels, certain arithmetic operations of increasing or reducing the appropriate x and y coordinates of pixels are executed to find boundary coordinates.Ribs form an additional element of the image which must be considered when searching for the boundary represented by polylines L i : {i = 2 . . .5}. Coordinates must be found which are located in front of ribs, as shown in the example from Fig. 12.For this reason, certain conditions were defined which enable pixel classification to identify subsequent points of polylines.In In Fig. 12d and g, the ribs have been clearly separated from the rest of the image, transformed into a uniform background.Background pixels belong to the set G 3 , while the pixels from the area occupied by the ribs belong to the set G 3 .The example from Fig. 12 is about two polylines: -L 2 , whose subsequent coordinates are found along the Y axis, while along the X axis, constant distances between them are kept.Fig. 12e, f, g.
-L 4 , whose subsequent coordinates are found along the X axis, while along the Y axis, constant distances between them are kept.Figure 12b, c, d While the coordinates of the polylines are determined within the anatomical area occupied by the ribs, two situations are considered: -While the coordinates are increased or decreased, the point may approach the edge of the area occupied by the rib, Fig. 13.-The starting point of the polyline may be located within the area occupied by the rib, Fig. 14.The method of proceeding in the situation from the example shown in Fig. 13a-d  the value of the x coordinate is x ≥ 2/5 • M and in addition, in this CT image, the edge of the liver adjoins muscles and ribs, as shown in Fig. 15b and e.
Let (x 0 , y 0 ) be the penultimate point of the polyline L 5 .In Fig. 14c (x  -B = {(x, y) : Figure 16b shows the initial situation before the first polyline R 1 is created.The proposed estimations make it possible to select and then build specified polylines R t , which evenly approximate the liver contour.The method of building subsequent polylines R i as a result of the defined estimations is shown in the diagram constituting Fig. 18. Figure 16c shows the model of the contour after first polyline R 1 is created, with the distances marked along the X and Y axes between the last point of this polyline P T = (xP T , yP T ) and the point P E = (xP E , yP E ). Figure 17a presents a model of the contour after another polyline R 2 is created, with the distances expressed by the differences between the coordinates xP E −xP T and yP T −yP E marked.Figure 17b contains the complete contour after the last polyline R 3 has been created (Fig. 18).

Stage 6. Finding points of polylines {R
The point P ST = (xP ST , yP ST ) is the starting point from which subsequent coordinates of the polyline R 1 are determined just as in the case of the polyline L 1 .The determination of the point P ST was presented at stage 1 of this method.The coordinates belonging to polylines {R i : i = 1 . . .6} are found in the same way as shown in Stages 3 and 4 of this method for polylines {L i : i = 1 . . .6}.The classification of pixels to defined sets of points containing set boundary conditions is used to execute specific arithmetic operations of increasing or reducing the appropriate x and y coordinates.If the boundary of the liver is approximated with polylines {R i : i = 1 . . .6}, there is no liver area occupied by the ribs, so none such needs to be included in the calculations.

Segmenting the Liver from CT Images Using the Approximate Contour Method
This section presents the method of segmenting the liver shape from CT images.The method is based on the approximate liver contour drawn in the previous section.

Segmenting the Liver Shape Within a CT Image of the Abdominal Cavity
The proposed method of segmenting the liver shape from a CT image makes use of the calculated values of coordinates identifying the liver contour using component polylines presented in Section 2 and determined by relationships (3) and (5).
In order to segment the liver shape from a CT image, two areas will be defined in the form of polygons W 1 and W 2 , which represent fragments of the image located outside the liver contour.Polygons W 1 and W 2 are shown in Fig. 19a  and b respectively.This way, the CT image is split into three parts: two polygons W 1 and W 2 , representing the background and the area Lv containing the liver shape presented in Fig. 19c.
Under the above assumptions, the segmentation was executed in such a way that a fragment of the CT image showing the liver, defined by the mapping g : M 2 → Z, was replaced with the area defined by the two polygons W 1 and W 2 , in which area all pixels were assigned the black colour.We obtain: Figure 19c presents a CT image with the liver shape segmented.

Completed Experiments and Research Results
Materials from the Image Diagnostics Department of the Gdańsk Provincial Specialist Hospital in Poland were used in the research on computed tomography image analysis.The CT images were acquired using the Siemens Somatom Emotion 6 apparatus.A contrast medium was used in the scanning.The exposure parameters for the abdominal cavity were: 130 kVp and 95 mAs for the venous phase, 110 kVp and 90 mAs for the arterial phase, 2 mm slice colimmation and the table speed of 15 mm/sec.The analysed images come from 120 different patients and include 60 cases in which no lesions were found as well as 60 cases with visible lesions, including: 30 different cases showing hemangiomas and 30 different cases with hepatomas.Figures 21a and g show cases with visible hapatomas, while Fig. 21d presents a single focused hemangioma.For every one of the 120 different cases, between eight and maximum sixteen CT slices were selected, from which liver areas were extracted using the segmentation method proposed here.As a standard, a CT examination can produce a set of between several dozen and about two hundred images of the cross-section of the abdominal cavity and the liver.However, only some of them will show the gradually growing and then shrinking cross-section of the liver with possible lesions in it.After consulting physicians, between eight and the maximum sixteen images showing subsequent cross-sections of the abdominal cavity and the liver were selected for the research work for every one of the 120 different cases analysed.

Dice's Similarity Coefficient
Dice's similarity coefficient was used to assess the accuracy of the method employed for segmenting the shape of the liver.  1 and 2. Dice's similarity coefficient [22] is a value making it possible to compare the percentage similarity of sets.These sets can be defined as areas with specific pixel numbers in the analysed digital image.
Let Lv auto ⊂ Z 2 be the fragment of the image obtained using the automatic shape extraction method and Lv manual ⊂ Z 2 signify the image fragment extracted manually by a radiologist.It was assumed that |Lv auto | is the number of pixels found in the area delineated using the automatic shape extraction, while |Lv manual | is the number of pixels in the area isolated by the radiologist.The number of pixels found in the common area is |Lv auto ∩ Lv manual |.Dice's similarity coefficient is defined as follows: As between eight and maximum sixteen CT slices were selected for every one of the 120 different cases, and from theses slices liver areas were extracted, the mean value of the Dices similarity coefficient was calculated as follows: The second column of Fig. 21 contains images with the liver shape manually delineated based on the contour traced by the radiologist.The third column contains the results, that is automatically extracted liver shapes.Table 1 and Fig. 20 show the results of three experiments based on measurements taken by three different physicians specialising in radiology.Results of experiments calculated using formula (8) for particular disease units are listed in the order of

Summary and Further Research Directions
The article presents a new method of automatically segmenting the liver shape from CT images of the abdominal cavity, which method uses the lumbar section of the spine as a seed point.After the starting point is identified, an approximate liver contour made up of joined polylines is drawn.These component polylines form the elements of two polygons eliminated from the image, which leaves only the segmented liver shape within the image.For the 1,330 CT images of the abdominal cavity and liver analysed, the Dice's similarity coefficient amounted to 81.3 %.Better segmentation results were obtained for CT images of the abdominal cavity and the liver without lesions.If they are compared to images showing lesions, the difference is about 5 %.The research on creating a mathematical description of liver contours in the analysed images shows that this is a key stage of the analysis and it may determine the accuracy and precision of the procedure of segmenting the liver from CT images.The research conducted on this subject can also be summarised in the form of the following conclusions: 1.The shape of the liver can be irregular and distorted in computed tomography images showing its crosssection.In the case of distortion of the edge as shown in Fig. 3b-f, the values of subsequent coordinates are approximated based on previously identified points marking the contour of the analysed shape of the organ.2. This publication presents a method in which the CT image of the liver is in every instance split into specific fragments for which the approximate contour is determined.This approach makes it possible to reduce the number of operations executed when determining subsequent coordinates defining the contour.3. The method of extracting the liver shape from CT images is universal and allows the shape of the organ to be extracted from the image for cases free of lesions or containing them.In order to fully confirm the suitability of the presented method, it must still be tested on a greater number of cases, and this is the subject of on-going research.4. The aim of the future work will also be reimplementation of the software created with C# for the SNAP/ITK environment.

Figure 2 A
Figure 2 A schematic of the automated liver segmentation method from CT images.

Figure 3
Figure 3 CT liver images with the contour marked.a A CT liver image without lesions.b Multi-focal lesions.c An image with a single focus near the edge of the upper lobe.d An image with the contour extracted using the authors method and the fragment of the CT image

Figure 4 A
Figure 4 A CT of the abdominal cavity and the liver.a An example input image b The model of the approximate liver contour with the direction of creating subsequent component polylines c A model of the liver contour.

Figure 5 A
Figure 5 A CT of the abdominal cavity and the liver.a, c, e Example images.b, d, f Liver contour models.

Figure 6
Figure 6 Example CT images of the cross-section of the abdominal cavity and the liver.a A CT image with the symmetry axes marked, which intersect above the lumbar spine section.b Determining the starting point.c An example CT image with the symmetry axes marked, which intersect above the lumbar spine section P ST .d Determining the point p 0 .

Figure 7 A
Figure 7 A CT image of the cross-section of the abdominal cavity and the liver.a A CT image with symmetry axes marked.b Projecting three points along the Y axis to the edge of the lumbar spine section.c Distances of points between the start and the end positions.d The determined point P SP .

Figure 8 A
Figure 8 A CT of the abdominal cavity and the liver.a An example image.b A contour model with the component polylines L 1 and L 6 marked.c Polyline L 1 .d Polyline L 6 .

Figure 9 A
Figure 9 A liver CT. a An example CT image with the length DY of the polyline L 1 marked.b Points of the polyline L 1 marked.c A model of the liver contour d Points of the polyline L 1 with pixels belonging to the set G 1 marked.e Points of the polyline L 1 with pixels belonging to the set G 1 marked.f Points of the polyline L 1 with pixels belonging to set G 2 marked g Points of the polyline L 1 with pixels belonging to the set G 2 marked.

Figure 10 1 Figure 11 A
Figure 10 Calculations needed to find the points of the polyline L 1 .Sets of points allowing pixels to be classified to determine polyline L 1 coordinates are defined in Section 2.3.1

Figure 12 A
Figure 12 A CT of the abdominal cavity and the liver.a An example CT image with the following distances marked: DY for the polyline L 4 and DX for the polyline L 2 .b Points of the polyline L 4 marked.c Pixels belonging to the set G 3 are marked with a uniform grey colour.d Pixels belonging to the set G 3 are marked with a uniform grey colour.

Figure 13
Figure 13 Determining the coordinates of the polyline L 2 .a Determining the initial coordinates of the second point of the polyline L 2 .b The first step of determining the point P 1 of the polyline L 2 .c Subsequent steps in determining the point P 1 .d The last step of determining the point P 1 .e Finding boundary points located below the ribs along the X axis.

Figure 14
Figure 14 Determining the coordinates of the polyline L 2 .a Determining the initial coordinates of the point P 7 of the polyline L 2 .b The first step of determining the coordinates of the point P 7 of the polyline

Figure 15 A
Figure 15 A liver CT-building the polyline L 2 .a,b Two anatomical areas approximated with the L 6 polyline are marked within rectangular boxes.c Points of the L 5 polyline and estimations of distances along the Y axis marked.The last point of the L 5 polyline, which is also the first point of the L 6 polyline, is marked in red.d Estimations of distances along the Y axis for points of the L 6 polyline.e Points of the polyline L 5 marked.The last point of the L 5 polyline (in red) is located in the close neighbourhood of the area occupied by muscles and the rib.
making it possible to find coordinates in front of the area occupied by the ribs is shown by the diagram from Fig.13e.The method of proceeding in the situation from the example shown in Fig.14a-dmaking it possible to find coordinates in front of the area occupied by the ribs is shown by the diagram from Fig. 14e.The polyline L 6 is built as an option.It approximates the boundary of the liver in two cases: 1.During the determination of coordinates of polyline L 5 the value of the coordinate is x ≥ 2/5 • M , and the value of the y coordinate has increased relative to the last point representing the boundary, Fig. 15a and c. 2. During the determination of coordinates of polyline L 5 ,

Figure 16 A
Figure 16 A liver CT. a An example image.b A model of the liver contour before the polylines from the set R are created.c Creating the polyline R 1 .

Figure 17
Figure 17 Building polylines belonging to the set R. a Creating the polyline R 2 b Creating the polyline R 3 .

Figure 18
Figure 18 Building polylines belonging to the set R.

Figure 19
Figure 19 Segmenting the liver shape within a CT image of the abdominal cavity.a The polygon W 1 containing the polyline L. b The polygon W 2 containing the polyline R. c The segmented shape of the liver.

Figure 20
Figure20 Test results for three measurements based on 1,330 CT images of the abdominal cavity and the liver originating from the three measurements shown in Tables1 and 2.

Figure 21
Figure 21 Segmenting the liver shape in CT images of the abdominal cavity.The first column shows example computed tomography images.The second column contains images with the liver shape

Table 1
Test results for three measurements based on 1,330 CT images of the abdominal cavity and the liver.

Table 2
Mean test results for 1,330 CT images of the abdominal cavity and the liver coming from the three measurements shown in Table1.number of cases.Table2shows the mean values based on all measurements taken by three different physicians and those taken from Table1.The method applied yielded the best results for CT images of the liver without lesions, and in this case Dice's similarity coefficient amounted to 84.8 % for 610 images.If lesions, i.e. hemangiomas and hepatomas, were present, Dice's similarity coefficient was equal to 79.65 % for 720 images. the