Segmentation of Cells From Microscopic
Segmentation of Cells From Microscopic
Segmentation of Cells From Microscopic
BACHELOR THESIS
Michal Lašan
Prague 2014
Hereby, I would like to thank my supervisor Jindřich Soukup and my classmate
Adam Blažek for their valuable advice.
I would also like to thank the staff of Working place of tissue culture - certified
laboratory at Nové Hrady, namely Monika Homolková and Šárka Beranová, for
performing the manual segmentation of the cells.
I am grateful to my parents for supporting me during the studies.
I declare that I carried out this bachelor thesis independently, and only with the
cited sources, literature and other professional sources.
I understand that my work relates to the rights and obligations under the Act
No. 121/2000 Coll., the Copyright Act, as amended, in particular the fact that
the Charles University in Prague has the right to conclude a license agreement on
the use of this work as a school work pursuant to Section 60 paragraph 1 of the
Copyright Act.
Abstract: In this thesis, we present a new method for the automatic segmentation
of mammalian cancer cells from time-lapse images obtained by a microscope based
on phase contrast. This method is a pipeline composed of basic techniques from
the field of image processing, mathematical morphology and the theory of graphs.
Its main idea is to utilize the presence of halo artifacts around the cells, which
cause the boundaries between the cells to be lighter than the rest of the image. It
follows up to the method proposed by Jindřich Soukup which is able to separate
the cells from the background. We compare this method to the watershed -
a publicly available algorithm from the field of mathematical morphology. We use
segmentation by a human expert as the ground truth. The presented method is
implemented in MATLAB and Java with a simple and intuitive interface. We
also attach a straightforward GUI editor of segmentation written in Java, with
the help of which a user can correct imprecisions in the segmentation, or even
create their own manual segmentation.
Preliminaries 6
Terminology and conventions . . . . . . . . . . . . . . . . . . . . 6
Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Blurring an image . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Thresholding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Mathematical morphology . . . . . . . . . . . . . . . . . . . . . . . . . 11
The basic measures of shape . . . . . . . . . . . . . . . . . . . . . 12
Skeletonization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
The watershed algorithm . . . . . . . . . . . . . . . . . . . . . . . 13
Machine learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
More image processing methods and concepts . . . . . . . . . . . . . . 15
Dijkstra’s algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1 Related work 18
1
6 The results 45
6.1 Tuning the parameters . . . . . . . . . . . . . . . . . . . . . . . . 45
6.2 The performance of our method and the watershed algorithm . . . 47
7 Conclusion 50
7.1 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Bibliography 52
List of Figures 56
Attachments 57
A - CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
B - The graphs justifying the values of the parameters . . . . . . . . . 58
2
Introduction
For research purposes, biologists create time-lapse microscopic image series of liv-
ing cells (see Fig. 1). Such records allow them to analyze the behavior and
characteristics of the observed cells over time. They are interested in the count
of the cells, their shape, movement, reproduction, etc. An analysis of these aspects
can be useful. For example, it can help evaluate the efficiency of a chemical
substance, the purpose of which is to kill the cells or to reduce their reproduction
rate 1 .
3
• Manual labeling performed by a human expert.
It is the most accurate way. However, it is quite a tedious and time-consuming
work.
• Automatic labeling performed by a computer.
Generally, such segmentation is less accurate. The results may vary de-
pending on the chosen algorithm and on the type of the cells in the image.
An automatic method tends to be more prone to imperfections of the image
and many other factors. By far, to our best knowledge, no universally
successful segmentation algorithm3 has been proposed.
Despite the numerous disadvantages, computer processing of microscopic
images is becoming more and more common. Even though less precise and not
universal, automatic segmentation is much faster than manual. After all, one can
always use an automatic method only for the images, where it works sufficiently.
In this thesis, we describe a new segmentation method which is focused
on processing images of live mammalian cancer cells obtained with a phase contrast
microscope [25] (see Fig. 1). These images are characteristic by the frequent
presence of so-called halo artifacts near the borders of cells. This causes the borders
to be typically lighter than cells and the background. The image series for this
work were provided by Working place of tissue culture - certified laboratory at
Nové Hrady. The experts from this place also performed manual segmentation
of a few images for us.
Our method takes advantage of the halo artifacts and its success depends
on their presence. The method is a fusion of subtle modifications of known
basic methods. It utilizes them in a non-traditional way. We are aware of the
imperfections of this method. This is why we include a straightforward GUI4 tool,
with the help of which a user can easily correct the inaccuracies.
Structure
At first, we describe the basic concepts of image processing related to this
thesis. In Chap. 1, we discuss the current related methods. We mention their
main concepts and compare them to our method. We also explain how this method
follows up to the method proposed by Jindřich Soukup [23], the supervisor
of this thesis.
In Chap. 2, we explain why we decided to develop a new method. We give
reasons for the choice of our approach. In Chap. 3, we explain the main idea of
the method. In Chap. 4, we complete the description of the method by explaining
its modifications and additional steps. In Chap. 5, we describe how we evaluated
the resulting segmentation. In Chap. 6, we evaluate our method together with
the watershed method, present the results and compare them. In Chap. 7, we
sum up the advantages and disadvantages of our method. We present our future
perspective.
Attachment 7.1, contains a CD with a GUI program enabling a user to segment
images of cells by the proposed method. It includes a subprogram for manual
3
A method which would work with any type of cells, under any viewing conditions.
4
Graphical user interface.
4
editing of the segmentation, alternatively for performing manual segmentation.
The CD contains a user manual for each one of the components.
Key contributions
The key contributions of this thesis are:
5
Preliminaries
In this chapter, we summarize the theory from the field of image processing which
we will need in this thesis. Some of the later mentioned terms might also have
a bit different meanings in another contexts. We only focus on the definitions
related to this thesis.
Firstly, we introduce the basic terminology and conventions used in this thesis.
Then, we describe Convolution and explain how it can be used to blur an image.
We explain the term Thresholding and mention a widely used thresholding method
- Otsu’s method [20]. We describe the principle of Skeletonization. Then we
briefly describe the watershed algorithm [2] - a simple, publicly available method
for digital image segmentation.
We describe very briefly the main idea of machine learning and mention
some of the state-of-the-art algorithms from this field. We also mention the key
principles of some more image processing methods and concepts. We provide
links to external sources for detailed explanations of more sophisticated concepts.
Lastly, a detailed explanation of Dijkstra’s algorithm [8] is provided.
• We define the operations ∪, ∩ : FZ2 →{0,1} × FZ2 →{0,1} −→ FZ2 →{0,1} . Let
union = b1 ∪ b2 and inter = b1 ∩ b2 . Then, the images union and
6
inter have the same domain as b1 and b2 and for (x, y) from this do-
main, the following applies: union(x, y) = sup(b1 (x, y), b2 (x, y)) and
inter(x, y) = inf (b1 (x, y), b2 (x, y)).
• We say, that two pixels at (x1 , y1 ) and (x2 , y2 ) are 8-connected, if they are
neighbors (can also be diagonal) - more formally, if |x1 −x2 | ≤ 1 & |y1 −y2 | ≤
1.
• We say, that two pixels at (x1 , y1 ) and (x2 , y2 ) are 4-connected, if they are
neighbors, but not diagonal - more formally, if they are 8-connected and
|x1 − x2 | + |y1 − y2 | ≤ 1.
The term 8-connected comes from the fact, that a non-border pixel has eight
8-connected neighbors. Analogically, such a pixel has four 4-connected neighbors.
The following definitions are all related to binary images:
• A maximal 4-connected area, the pixels of which have the value of 1, is called
an object. If its pixels have the value of 0, it is called a hole.
7
Convolution
One-dimensional convolution is an operation which is given two real functions
and returns a real function. Let ∗ be the symbol representing this operation. Let
FR→R be the symbol representing all one-dimensional real integrable functions.
Then we write:
∗ : FR→R × FR→R −→ FR→R (1)
Let f, g be one-dimensional real functions: f, g : R −→ R. This is the formula
for the value of convolution of f and g at the point x :
Z ∞
(f ∗ g)(x) = f (t)g(x − t) dt f or x ∈ R (2)
−∞
• We ”shift” g0 to x ; formally, we create a function g00 (see Fig. 3a), such as:
8
(a) Flipping g around the y axis followed by shifting it to
the point x. The result of this operation is g00.
sum of the values of its neighbors. The weights and the size of the neighborhood
are determined by g. We define the size of the convolution core as the maximum
distance from the origin: (0, 0) to its pixel with a non-zero value. In practice,
the convolution core is often a lot smaller than the image.
A digital image has a finite domain, which introduces the problem, how to
treat the area out of its domain during the convolution. One of the appropriate
solutions is to symmetrically extend the image. The amount of the extension in
pixels must be greater than or equal to the size of the convolution core. In Fig. 5c,
you can see a greatly symmetrically extended image from Fig. 5a.
The shape of the convolution core influences the result of the convolution.
If we choose an appropriate shape, we get a blurred image. One of such shapes is
the well-known Gaussian function. This function is symmetric around the origin,
so it produces an omni-directional blur. As you can see in Fig. 5b, such blurring
rids the image of a certain amount of noise and the inner structure of cells. In
Fig. 4, you can see an example of the Gaussian core. In these visualizations,
the function is not centered at the origin. However, to make the convolution work
properly, the Gaussian core must be centered at the origin, otherwise it not only
blurs, but also shifts the image.
The Gaussian core has one parameter - variance. The higher the variance,
the larger the core is and the more substantial blurring is performed (Fig. 4c).
9
Alternatively, this core can have another parameter - diameter. Here is the purpose
of it: g(x, y) is set to 0 in the places where x > diameter/2 or y > diameter/2.
In other words, a smaller symmetric segment of the Gaussian function is cut out
(Fig. 4d). We utilize a core similar to this in our method.
(c) A core with a higher variance. (d) A core with the same variance
as 4c, but a smaller diameter.
Thresholding
Thresholding is a transformation of a gray-scale image to a binary image. Formally:
where T is the symbol for thresholding. It has two input variables. The first
one of them is a gray-scale image and the second one of them is a threshold.
Let f be the input image, let t be the threshold. The output binary image b
is constructed as follows:
b(x, y) = 0 ⇔ f (x, y) ≤ t
b(x, y) = 1 ⇔ f (x, y) > t (10)
f or x, y ∈ Z
There are several strategies how to choose the value of the threshold. It can be
chosen either manually or automatically. The most common automatic solution
is Otsu’s method [20]. As we can see in 10, thresholding separates the pixels into
two classes. The aim of Otsu’s method is to find the value of the threshold which
minimizes the sum of the variances of the original values of the pixels inside these
two classes. Formally:
10
(a) The original image. (b) The blurred image.
min var({f (x, y) | f (x, y) ≤ t}) + var({f (x, y) | f (x, y) > t}) (11)
t∈R
Thresholding can be used for isolating the halos from the image. See Fig. 6
for a demonstration of the result of Otsu’s method.
Mathematical morphology
Mathematical morphology is a field studying shapes. Its methods can also be
applied to patterns in binary images.
The basic operations of mathematical morphology are:
• Erosion - setting the value of every pixel to the minimum value among its
neighborhood. This operation ”deflates” patterns; it decreases their size.
• Dilation - setting the value of every pixel to the maximum value among its
neighborhood. This operation ”inflates” patterns; it increases their size.
11
(a) The gray-scale image.(b) The thresholded im- (c) The thresholded image
age. superimposed on the origi-
nal.
Figure 6 A part of an image before and after thresholding using Otsu’s method.
• Circularity - let SC be the area of the part of the pattern which lies in
the circle centered at the pattern’s centroid with the area equal to the area
of the pattern. Then, circularity is the ratio of SC to the area of the pattern.
Thus, it is a number in the range [0, 1].
Skeletonization
Skeletonization is a transformation of a binary image. Formally:
12
is flammable. Let us suppose that the speed, with which the fire progresses through
the pattern is the same in all its places at every moment and it is more than
zero. Then, the skeleton consists of the points, where at least two distinct waves
of the fire meet.
One of reasonably appropriate and computationally fast approaches to skele-
tonization is to iteratively peel pixels off the pattern until there is only a thin
line of it left [14]. The algorithms based on this approach may differ in the way
they peel off the pixels. Accordingly, the skeletons they produce may differ too.
In Fig. 7 we can see an example of such a difference. The skeleton produced
by Hilditch’s algorithm [12] seems to be more compliant with the mentioned
intuitive definition of skeleton than the skeleton created by the method available
in MATLAB [13]. The output of Hilditch’s algorithm runs along the main course
of the pattern more accurately. Both methods create 8-connected skeletons.
13
inner structure of the cell. A more substantial blurring might solve this problem.
However, it might cause undersegmentation 6 , as some information related to
boundaries between cells might be lost as well.
Machine learning
The main idea of machine learning can be described as follows:
Let us consider a function f :
f : Rn −→ R (14)
This function is given a vector of features as the input. The features can be
for example some data from a certain sector of an image - pixel intensities,
gradients, etc. The object represented by the features is called a sample (the sector
of an image in this case).
This function outputs a single real number: a verdict. The verdict can be
for example an indicator, whether there is a cell center at the given sector
of an image, in which case the value of the verdict might be 0 or 1. More
generally, if we want to divide the samples into a finite set of classes, we are facing
a classification problem and thus f is called a classifier.
6
The segmented areas contain several cells (see Chap. 5).
14
The problem is, that we do not know the function. However, we have some
pairs (features, verdict) available - these form the training set. The goal of machine
learning is to use the training set to construct the function f, so that when f
is given a previously unknown vector of features, it outputs a verdict which is
as close to the truth as possible.7 The process of constructing f is called training
the classifier.
A machine learning algorithm describes, how the function f is constructed
from the test set. Some of the main state-of-the-art algorithms are:
• Local binary patterns [10] - ways how to store the information about
the neighborhood of a pixel. They are usually used for pattern recognition.
15
Dijkstra’s algorithm
In this section, we explain, how this algorithm [8] works and enumerate its main
procedural components and the data structures it uses. The main purpose of this
description is to adopt a consistent terminology regarding the algorithm. This
will allow us to comprehensibly introduce some modifications to it further in this
thesis.
This is an algorithm for finding the cheapest paths in an oriented graph with
priced edges from a certain node to all other nodes. It accomplishes this goal by
a smart successive visiting of the nodes, beginning at the given starting node. It
maintains a list of the nodes to visit. Each node is assigned a so-called path record
when inserted into this list. The path record consists of:
From the backward links, the path leading to the node can be reconstructed.
The next node to visit is the node from the list with the lowest price in its path
record 8 . It is a proven fact, that as long as the prices of the edges in the graph
are non-negative, the path to the next node to visit is the cheapest one from
the starting node to this node. Thus, at the moment when the path to the current
next node to visit is all we want to know, we can finish. Such a statement can be
encapsulated in the end condition of the algorithm.
During the visit of a node, its neighbors are updated, which might include
assigning new path records to them (see Algorithm. 1) or adding them to the list.
This is called updating neighbors (see Algorithm 2). However, no updating of
neighbors takes place, if the continuing condition is not satisfied. This condition
is always satisfied in the basic version of the algorithm, but we include it in this
description, because we will need it later on. Algorithm. 3 manifests Dijkstra’s
algorithm, using the formerly introduced terminology.
Algorithm 1 Procedure
assignNewPathRecord (current node, previous node, new price)
current node.createNewPathRecord()
current node.path record.price ← new price
current node.path record.previous node ← previous node
8
For this reason, it is effective to implement this list as a heap.
16
Algorithm 2 Procedure
updateNeighbors(visited node, list)
for each neighbor of visited node do
if neighbor ∈ / list then
list.insert(neighbor)
end if
price from visited ←
visited node.path record.price +
priceOfEdgeBetween(visited node, neighbor)
if price from visited < neighbor.path record.price then
assignNewPathRecord (neighbor, visited node, price from visited)
end if
end for
17
1. Related work
In the latest related work, several segmentation strategies are employed.
Wang et al. [11] firstly use a support vector machine classifier fed by pix-
el intensities, gradients and local binary patterns to separate the cells from
the background. Then they use the watershed method to separate individual cells.
To reduce the oversegmentation caused by this method, they detect the centers
of the cells with the help of an AdaBoost algorithm fed by features based on
the wavelet transform.
Pan et al. [21] have developed an algorithm based on a conditional random
field, so that it is capable of separating individual cells.
The two mentioned methods have been tested on images containing cells
attached to each other. To the contrary, the following two methods have only been
tested on images, where there is at least a small gap between every pair of cells.
Hence, it remains unclear, how they would succeed on more intricate data.
Li et al. [18] use a combination of mathematical morphology and an active
contour model to segment individual cells.
Yin et al. [24] use advanced deconvolution methods to get rid of halos and thus
separate individual cells. To compute the necessary convolution core, they exploit
the characteristics of the phase-contrast microscope. The cells are subsequently
segmented by thresholding, using Otsu’s method.
The existing related methods still have some disadvantages and thus proposing
alternatives might be helpful. It can also help others by clarifying, how well such
an approach works.
Our method is conceptually much simpler than all the mentioned methods.
Unlike the last two methods, it has also been tested on images, where the cells
are attached to each other. In contrast to the fourth method, it does not require
any precise knowledge of the used microscope and takes advantage of the halos.
Differently from the first two methods, it is not based on machine learning. It
does not require any training set and it is less computationally demanding.
On the other hand, it means that it is much less adaptable to impurities
or uneven distribution of illumination thorough the image. It is dependent on
the presence of halos. It relies on the assumption that the interiors of the cells
are darker than the halos, so light points inside the cells might cause its failure.
It does not take advantage of colors, nor the inner structure of the cells, nor
the shape of the cells. The independence of the color, structure and shape
can be advantageous - the method is theoretically more universal. However,
a lot of information is ignored this way. It is also dependent on a good setting
of its parameters.
However, due to its simplicity, it could be used in connection with a more sophis-
ticated method, just like the watershed method is used in Wang’s approach [11]]
together with a machine learning method.
The following two methods only focus on the separation of groups of cells from
the background; equivalently the detection of cell clusters. Their approaches differ
a lot.
Soukup et al. [23] take advantage of the time-lapse character of the image
series to separate the cells from the background. They observe that the cells almost
18
always move in between subsequent images. Thus, they compute the difference
of such images to identify the areas, where the cells are located. This method
also relies on parameters - the sensitivity of response (resistance to noise) and
the span between the images, the difference of which is computed (depends on
how quickly the cells move).
Ersoy et al. [9] use geometric and active contour methods to separate the cells
from the background.
Our method only focuses on segmentation of individual cells. It does not
deal with separating the cells from the background. Quite the opposite, it presumes,
that such a separation has already been performed and expects the result of it
at the input. It uses the results of Soukup’s [23] method.
19
2. Analysis and methodology
In this chapter, we explain the reasons which led us to our approach. We describe
the process of creating the proposed method.
2.1 Analysis
(a) (b)
(c) (d)
As we can see in Fig. 2.1, the cells appear in various shapes, colors and have
diverse inner structure. The quality of the images is not optimal - the cells
tend to be a bit blurred. Probably the only aspect which they have in common
is the frequent presence of halos near their borders.1 This observation led us
to the conviction, that we were going to take advantage of it. We decided to focus
on detecting boundaries between the cells with the help of halos and not to
take advantage of color, shape and structure of the cells, since these characteristics
vary a lot in the images and the quality of the images is far from optimal. Moreover,
we wanted to avoid the need of a training set and keep the principles of this
method simple. It is highly probable, that a highly advanced method would be
needed if we decided to take advantage of these properties.
1
In other words, their borders tend to be lighter than the rest.
20
2.2 Methodology
The method which we have finally created is quite straight-forward and has
the character of a pipeline. This comes from the way we were constructing it.
In each stage of the development, we intuitively considered, what step to take
next. We took the step which we thought would improve our situation the most.
The criterion for how much the situation would improve was based on simple
observance and gut feeling at first. We knew what the final segmentation should
look like. We estimated, how far from it we were before and after the considered
step. Finally we compared these two estimations.
In the further stages of the development, we focused on addressing the most
common problems of the method by editing the existing steps and also by adding
some additional steps.
Generally, the steps described in Chap. 3 were included on the basis of gut
feeling - these are the core steps of the method. The steps described in Chap. 4
were included in order to fix some frequently occurring problems.
21
Figure 3.1 A diagram displaying the main steps of the method.
22
3.2 Thresholding and Skeletonization
We suppose that halos accompany the majority of the boundaries between the cells.
We utilize thresholding to isolate them in Contour - see Fig. 3.2. We use Otsu’s
method to compute the threshold.
23
3.3 Connecting
Skeleton is incomplete - many times, some sections of the real boundaries are
missing. When this happens, there is often a branch present in Skeleton (Fig. 3.4).
The idea of this step is to fix this problem. Our aim is to reasonably connect
the end-point of every branch of Skeleton to another point of Skeleton and
subsequently add the interconnecting paths to Skeleton. For this purpose, we
will construct an interconnecting algorithm which will be launched individually
from every end-point of Skeleton to find a suitable interconnecting path.
3. The length of the starting and the finishing section inside Contour
is limited (contour length) - it forbids paths like the red one in Fig. 3.5a.
24
5. It must be as short as possible (short) - the section of the boundaries
which is missing in Skeleton rarely extends the length of one cell. Together
with the criterion n. 4, this criterion makes up the price of the path. The price
comprises a weighted sum of these two criteria.
6. It must be the one with the lowest price among the paths which
satisfy the criterion n. 1 and have the same end-points (cheapest) -
it forbids paths like the blue one in Fig. 3.5b. A narrow path interconnecting
the same pixels, but staying in Contour for the whole time, would be
cheaper. It would be surely shorter and also lighter, because the pixels
in Contour are lighter than the rest.
(a) The red path is forbidden; (b) Samples of three types of in-
its starting section in Contour is terconnecting paths; only the green
too long. The green one is OK. one is allowed.
Figure 3.5 A demonstration of the purpose of some of the criteria for the inter-
connecting path. Skeleton is black, Contour is dark-gray.
25
non-negative prices in order to guarantee the proper functionality of the algorithm.
Thanks to this, the criterion short will be satisfied, because the longer a path is,
the more expensive it gets. We can view a pixel as an obstacle on the path which
is the same, no matter where we come from to walk through it. It follows, that
all edges leading to the same pixel will have the same prices.
Now, it remains to suitably define the prices of the edges in order to satisfy
the criterion light. The lighter a pixel is, the cheaper the edges leading to it should
be. We can postpone this problem and state, that the price of an edge will be
equal to the intensity of the pixel which the edge leads to. You might have noticed,
that if such a graph was built now directly atop Gray, we would not achieve
the desired result, because the lighter a pixel, the more expensive the edges leading
to it would be. However, this is what we meant by ”postponing”: a suitable
transformation of the intensities in Gray can be performed, so that if we build
a graph with the described characteristics atop the image after the transformation,
the pricing of the edges will reflect the criterion light.
So, let us accurately describe how we will build a graph from the transformed
image:
• For each pixel, there are edges to all of its 8-connected neighbors. No other
edges exist.
• Then, the price of a path is the sum of the prices of the edges contained by
it.
• We also define the length of a path as the sum of dist(a, b) for every edge it
contains.
26
With the respect to the criterion light, a satisfactory function could be for
example f (x) = −x. Different functions give us different ratios between the cri-
teria light and short. We tested several of them, including various forms of
the exponential function, polynomial functions and some custom-made functions.
The function f (x) = −log(x) turned out to be the most appropriate one of
them2 . As you can see in Fig. 3.7, the new intensity of a pixel rises very quickly
to the infinity as its original intensity decreases to 0, which greatly emphasizes
the difference between dark and light pixels (Fig. 3.8). This might be the reason
for the suitability of this function.
The zero intensities are transformed to the infinity, the practical consequence
of which is that Dijkstra’s algorithm never visits such pixels, as long as there
are still some pixels with non-zero original intensities reachable from the starting
pixel before the algorithm finishes. It follows, that the prices of the paths crossing
pixels with zero original intensities are mutually incomparable.
By far, our algorithm satisfies the criteria light, short and cheapest. The re-
maining ones will not be so hard to satisfy. The criterion skel finish can be
satisfied by suitable formulations of the end condition (see Algorithm 5) and
the continuing condition (see Algorithm. 6) of Dijkstra’s algorithm.
2
According to the further mentioned evaluation of segmentation (Chap. 5)
27
However, the criteria contour leave and contour length require some additional
information about the found paths to be computed - the path records need to
be extended, which must be accompanied by the extension of assigning a new
path record (see Algorithm.√4). In this algorithm, dist(a, b) is 1, if a and b are
4-connected, otherwise it is 2. On the basis of the information in the extended
path records, the end condition will then determinate, whether the path leading
to the currently visited node satisfies all the criteria (see Algorithm 5).
So, let us enumerate the fields which we need to include in the path record
besides the price and the link to the previous node. For each one of the fields and
also for each value of a field, its shorter name is written in the parentheses, with
the help of which we will refer to it later on.
• The state of the path with the respect to Contour (state) - it can be one
of:
• The length of the first continuous section of the path in Contour (length first).
28
Algorithm 4 Procedure
assignNewPathRecord (current node, previous node, new price)
new record ← copyOf(previous node.path record )
new record.price ← new record.price + new price
new record.previous node ← previous node
dist ← dist(current node, previous node)
if new record.state = contour first then
if current node ∈ Contour then
new record.length first ← new record.length first + dist
else
new record.state ← contour between
end if
else if new record.state = contour between then
if current node ∈ Contour then
new record.state ← contour second
new record.length second ← dist(current node, previous node)
end if
else if new record.state = contour second then
if current node ∈ Contour then
new record.length second ← new record.length second + dist
else
new record.state ← contour out
end if
end if
current node.path record ← new record
Algorithm 5 Function
endCondition(visited node)
return visited node ∈ Skeleton and
visited node.path record.state = contour second and
visited node.path record.length first < certain limit and
visited node.path record.length second < certain limit
Algorithm 6 Function
continuingCondition(visited node)
return visited node ∈
/ Skeleton
29
4. The additional steps and
the modifications to the method
In this chapter, we identify some of the frequently occurring issues of the described
method and address them by suitably modifying it or by including some more
steps in it. So far, the method has not utilized the separation of the cells from
the background; equivalently, the output of the detection of clusters of cells. It
is a binary image, the pattern in which denotes the areas, where the cells are
likely to appear. From now on, we will call it Clusters. This chapter includes
the utilization of it. Soukup’s algorithm [23] focuses on the detection of clusters
and its result are close to the ground truth. No other methods addressing this
detection are publicly available. Thus, Clusters used in our method is the output
of this algorithm.
Several parameters are introduced in this chapter. The settings of the parame-
ters of this method are discussed in Sec. 6.1. We divide the parameters into two
groups:
• The inner parameters - the ones which are not modifiable by the user,
because they only weakly depend on the input data and we tuned them
properly according to the evaluation. They are marked as blue. One of
them is also tolerance at the end of Sec. 3.3.
• The regular parameters - the ones which are modifiable by the user. Their
optimal settings depend on the input image; mainly on the sizes and shapes
of the cells and on how much the image is blurred. They are marked as red.
4.1 Blurring
If Gray is blurred after its creation, the subsequently created Contour has
a more definite shape, less influenced by noise and the inner structure of the cells.
The Gaussian convolution core turned out to be suitable for this purpose1 . Such
1
According to the evaluation (Chap. 5)
30
a core has two parameters - diameter and variance. The result of the method
greatly depends on their settings. The higher their values are, the less detail is
preserved in Gray, which is only profitable to a certain extent. Their optimal
settings mainly depend on the size of the image and on how much the image is
already blurred.
31
(a) Gray. (b) The lower (c) The higher (d) Their combi-
threshold. threshold. nation.
32
Contour = Contour ∪ S
(4.1)
Skeleton = Skeleton ∪ S
Figure 4.3 Enriching Skeleton by the distant boundaries of Clusters - all the
displayed binary images are superimposed on Gray.
33
(a) Some end-points of Skeleton are (b) The red lines denote the extension
out of Clusters. of Clusters.
34
angle.
The continuing condition then becomes the conjunction of the existing sub-
condition (that the node cannot be in Skeleton) and the new sub-condition.
In this moment, you might question the existence of the criterion contour length
in Sec. 3.3.1 and the existence of all the elements of the algorithm stemming from
this criterion (the extra fields in the path records and the extra sub-conditions in
the end condition). The main purpose of this criterion is similar to the purpose
of this modification - to eliminate too ”sharp” connections.
The fact is, that the method could now work without this criterion. However,
the graph 7.1 in Attach. ?? shows, that increasing the value of tolerance results in
worse performance of the method. Note that increasing the value of tolerance is
similar to weakening this criterion and setting it to infinity is equivalent to omitting
the criterion. From this, we concluded that keeping this criterion in our method
is beneficial.
(a) The meaning of the parameter angle.(b) The computation of the tail angle of
. a branch in Skeleton.
Figure 4.5 The cone-shaped clipping of the space searched by the connecting
algorithm.
35
a pixel of the boundary of the cell, which is close to they place they ”grow”
from, creating a small object this way (tags ”2a” in Fig. 4.6a)2 .
In this case, the knowledge of the minimum area of a cell can help a lot. If we
are sure, that a cell cannot be smaller than a certain specified minimum, we can
eliminate objects smaller than that. We introduce area: a regular parameter of
the method. It specifies the minimum size of a cell in pixels. Its optimal setting
depends on the size of the observed cells in proportion to the size of the image.
In the output of the connecting algorithm (the Skeleton enriched by the in-
terconnecting paths), we identify all the objects the area of which is smaller
than area. We ”fill them up” - set the values of their interior pixels to 1. Then
we skeletonize the whole image (see Fig. 4.6b) using the same algorithm as in
Sec. 3.2. Note that the skeletonization shifts the boundaries closer to the middle
of the small objects.
An alternative to this approach could be merging such objects with their neigh-
bors. However, this would introduce the question, which neighbor to choose.
Regarding the small sizes of the considered objects and also the fact, that they are
often created due to some sort of inaccuracy, we think that the proposed solution
based on skeletonization is the more elegant one.
(a) The output of the connecting algo- (b) The boundaries in Fig. 4.6a after
rithm. Skeleton is yellow, the paths the skeletonization of the small objects.
found by the connecting algorithm are
green.
2
Unfortunately, it also happens, that they are connected to the opposite boundary of the cell
via a path crossing the cell (tags ”2b” in Fig. 4.6a). This also occurs when Skeleton is present
inside a cell (tags ”2c” in Fig. 4.6a). Neither this section, nor this thesis present solutions to
these problems, if the objects segmented this way are not distinctly small.
36
4.3.5 Double connecting
This modification addresses the following problem:
Sometimes, there is only a short fragment of Skeleton present in the middle of
a real boundary between the cells. If the fragment is short enough, its end-points
are declared indeterminate (see Sec. 4.3.3). When looking for optimal connecting
paths from them, the searched space is not clipped. This is why they might be
connected to the same side of the real boundary (Fig. 4.7), which is not the desired
result. We would like one of them to connect to another side of the boundary.
However, after the subsequent skeletonization (see Sec. 4.3.4), one of the end-
points of the former short fragment becomes the end-point of a new, longer
branch. It is possible that it is not indeterminate now. For this reason, we
run the connecting routine for the second time, which is followed by the second
skeletonization of its output. During the second run of the algorithm, the end-
point marked as red in Fig. 4.7 will be connected to the other side of the real
boundary.
Let us call Boundaries the output of the first iteration of the connecting
algorithm and the subsequent skeletonization (Sec. 4.3.4). We must be aware
that Boundaries will most probably exceed the enriched Contour (Sec. 4.3.1)3 .
We need to include them in Contour before using Contour as the input to
the second iteration of the connecting algorithm. More formally, we need to
perform the following operation:
Figure 4.7 The reason for the second run of the connecting algorithm.
3
Because the connecting algorithm adds new interconnecting paths and the skeletonization
moves the resulting boundaries.
4
All the interconnecting paths added by the first iteration of the connecting algorithm lie
inside Clusters (see Sec. 4.3.2). Skeletonization of small objects ”shrinks” the boundaries -
most of the time, it does not move them out of Clusters.
37
Figure 4.8 A diagram of Enhanced connecting.
38
4.4.1 Adjusting the outermost boundaries
In the outputs of the previously described steps, we observed, that the outermost
boundaries of the cells (equivalently the boundaries between the cells and the back-
ground) were quite distant from the outermost boundaries of the test objects
(the objects segmented by the human experts). In addition to that, the boundaries
of the test objects were often located somewhere between the boundaries of our
objects (the objects segmented by our method) and the boundaries of Clusters
(see Fig. 4.9a). This is because our method reacts to the intensities of pixels,
whereas Soukup’s method for detecting clusters reacts to the movement of the cells.
It seems that the truth is often ”somewhere between”. This inspired us to push
Boundaries (the output of the previous steps of our method) a bit towards
the boundaries of Clusters.
In order to do this, we firstly insert the boundaries of Clusters into Bound-
aries. Secondly, we detect the border objects, which were created by this insertion.
Those are the objects, which lay inside Clusters and which have some parts
of their boundaries common with the boundaries of Clusters (see Fig. 4.9c).
The idea is, that the border objects should be completely new objects squeezed
between the boundaries of our objects and the boundaries of Clusters. We deduce
it from the observation, that these two boundaries differ and that Boundaries
are most of the time surrounded by the boundaries of Clusters. However, as we
see in the red circles in Fig. 4.9c, it is not always like this and the border objects
sometimes comprise the cells. This is why we must filter these border objects.
The circularity turns out to be a reasonable filtering criterion, because the bor-
der objects, which we actually want to detect, are often much more elongated
than the cells. This is why we introduce another regular parameter of the method:
circularity. Then, we throw away all the objects with the circularity higher than
circularity from the border objects (see Fig. 4.9d).
Subsequently, we fill the interiors of the border objects up - we mark them as
boundaries - and we skeletonize Boundaries. This is the same principle as in
Sec. 4.3.4. The skeletonization causes the outermost boundaries of our objects to
move a bit outwards (see Fig. 4.9b) As you can see in this figure, Boundaries
contain branches inside objects (see the red circles). These inner branches are
unnecessary, so they are subsequently erased.
The optimal setting of the parameter circularity mainly depends on the dom-
inant shape of the observed cells.
39
(a) A comparison of the outermost (b) Boundaries after the skeletoniza-
boundaries. The green lines are Bound- tion of the filtered border objects.
aries, the blue ones are the bound-
aries of Clusters and the red ones are
the boundaries of the test objects.
(c) The firstly selected border objects - (d) The filtered border objects - they are
they are marked as blue. marked as blue.
40
Figure 4.10 An example of identifying the background - it is marked as blue.
• Two more steps after Connecting are added - see Sec. 4.4.1 and 4.4.2.
41
Figure 4.11 The final diagram of the method.
42
5. The evaluation metrics of
the segmentation
We had a few reference images available - the images, a manual segmentation of
which has been performed by human experts. Let us call the segmented areas in
such a segmentation the test objects. Let us call the segmented areas determined
by Boundaries our objects.
Let us describe the evaluation metrics. Firstly, we initialize the global variables
Fn, Tp, Fp (false negative, true positive, false positive) to zeros. For each test
object t, we do the following (see Fig. 5.1):
• We compute tFn - the size of the area of t, which is not included in o (false
negative).
• We compute tFp - the size of the area of o, which is not included in t (false
positive).
– Fn = Fn + tFn
– Tp = Tp + tTp
– Fp = Fp + tFp
43
• The recall : R = Tp/(Tp + Fn).
We use the value of F as the number expressing the quality of the segmentation.
Besides this, we also consider the ratio of the number of our objects to the number
of thetest objects as another measure. The closer their values are to 1, the more
accurate the segmentation is.
The imperfections of the segmentation can be basically divided into two types:
The lower the undersegmentation, the higher the precision, because Fp decreas-
es (imagine the blue object in Fig. 5.1 shrinking). The lower the oversegmentation,
the higher the recall, because Fn decreases (imagine the green object in Fig. 5.1
shrinking). The f-score is the harmonic mean of the precision and the recall, so it
comprises the influence of the both types of imperfection evenly.
44
6. The results
In this chapter, we show the results of the evaluation of this method (see Chap. 5
for details). We also evaluate the standard watershed algorithm the same way
and compare the results. We do not evaluate any of the methods mentioned in
Chap. 1, as none of them is publicly available.
We evaluated these methods on 8 manually labeled images - we call them
the test set. For each one of the images, we calculated the precision, the recall,
the f-score and the ratio of the number of our objects to the number of the test
objects (Counts ratio). We also measured, how long it took to segment each one of
them (Time elapsed ). Then, we computed the means and the standard deviations
of these quantities. We took the mean f-score followed by the mean Counts ratio
as the main measures of quality of the segmentation.
The test set contained several types of cells - they were taken from 4 time-lapse
series. Even though the number of the images was not very high, they contained
the total of 1907 cells. Thus, the average number of cells in one image was 238.375.
The standard deviance of the count of cells in one image was 107 and the minimum
count in one image was 122, so the weight of every image did not vary a lot. This
is why we think that the presented results are credible.
We use the implementation of our method, which is provided on the at-
tached CD. We use the implementation of the watershed provided in MATLAB
R2013a [13].
45
In Attach. 7.1, the shown graphs demonstrate, that at the presented settings
of the parameters, the functions of the mean f-score of the methods on the test
set have local maxima. We verify it by performing this for every parameter: we
move its value to both sides while fixing the values of the remaining parameters.
If the mean f-score decreases after moving the value of every parameter, we have
reached a local optimum2 . The graphs demonstrate this fact.
We came to the following values of the inner parameters of our method:
The performance of our method greatly depends on the settings of all of its
parameters.
We came to the following values of the parameters of the watershed method:
• diameter = 103
• variance = 17
The parameters of the watershed method are the parameters of the Gaussian
convolution core, which is used to blur the image converted to gray-scale before
the algorithm is launched. The final performance of the watershed greatly depends
on their values. If they are the same as the ones used for our method (14, 8),
the mean f-score of the watershed reaches only about 0.4 on the test set.
In Fig. 6.1, you can see a comparison of the Gaussian convolution cores used
for our method and for the watershed method. Even though the maximum value
of the second one is much smaller, it causes a more substantial blurring, because
it is the ratio of the weights between the pixel and its neighbors what counts
of 109 evaluations. The evaluation of one image takes approx. 40 seconds, which sums up to
320 seconds for eight images - the whole test set. This sums up to 109 · 320 seconds in total,
which is approx. 10147 years. Of course, we could accelerate the implementation of the method
or parallelize the evaluation, but this would not shorten the total amount of time to a reasonably
bearable length.
2
Among the set of sampled values of parameters.
46
during the convolution. The watershed works better with a more substantial
blurring than our method. This might be because the watershed profits from
the increased smoothness of the interiors of the cells towards their borders. Howev-
er, the halos are not so distinct after a more substantial blurring, which decreases
the performance of our method.
(a) The core used for our method. (b) The core used for the watershed al-
gorithm.
Figure 6.1 A comparison of the Gaussian cores used for our method and for
the watershed method.
47
(a) The blurred image for our method. (b) The blurred image for the watershed.
(c) The segmentation by our method. (d) The segmentation by the watershed.
(e) The matching map of our method. (f ) The matching map of the watershed.
Figure 6.2 A comparison of the results our method and the watershed method.
time of the watershed is about 2.5 times lower, with a much smaller deviation.
The watershed is also a lot simpler method.
48
F-score Precision Recall Counts ratio Time elapsed
Mean value 69.28 % 67.47 % 71.99 % 131.32 % 44.7824 s
Standard deviation 5.74 % 8.20 % 6.95 % 24.85 % 13.3272 s
Table 6.2 The results the watershed method on the test set.
49
7. Conclusion
We proposed a new method for the segmentation of live mammalian cancer
cells from microscopic images. This method is composed of simple methods
from the field of the mathematical morphology and the theory of graphs. Its
functionality is dependent on the presence of the halos between the cells. Its main
assumption is that the boundaries are lighter than the rest. It is not based on
machine learning, which limits its universality. On the other hand, it does not
require any training set and is not so computationally demanding. The method
forms quite a complicated pipeline of mostly simple operations, many times just
some heuristics. It is highly dependent on the settings of its parameters. It ignores
much of the information present in the input image. However, it works well on
the images, where the boundaries between the cells are distinctly light.
We proposed an evaluation metrics for the overall quality of segmentation based
on the accuracy of the segmented areas. According to this metrics, we compared
the results of our method to the results of the publicly available watershed
algorithm. The results were not very convincing due to the deviations, however,
our method reached a higher mean f-score than the watershed. As our evaluation
showed, both these methods heavily rely on the settings of their parameters.
Despite the fact, that the watershed originally does not require any parameters,
its results significantly improved after a heavy blurring of the input image. Our
method utilizes blurring too, but in addition, it contains several more parameters,
which need to be tuned in order to optimize its performance. This is definitely its
serious drawback.
We implemented our method and the evaluation based on the proposed metrics
in MATLAB [13], including subprograms written in Java for some low-level
subroutines, such as Dijkstra’s algorithm [8] or matching the objects segmented by
our method to the objects segmented by human experts. We also created a GUI
for this method.
We implemented a GUI segmentation editor in Java. With this program,
a user can easily correct the mistakes in the output of our method. Moreover,
this program can also serve as an intuitive and straightforward tool for manual
segmentation of cells, which can be subsequently utilized for training a machine-
learning classifier.
50
idea is to start experimenting with neural networks. Firstly, we plan to get up
to date with the knowledge available in this area. Secondly, we want to choose
an appropriate approach. An inspiring one is present in a paper by IDSIA about
segmenting neuronal membranes with the help of deep neural networks [6]. They
used graphical processing units to implement fast neural networks. They also
employed the concept of deep learning [1]. They fed the networks directly with
the pixel intensities and achieved remarkable results.
51
Bibliography
[1] Yoshua Bengio, Aaron Courville, and Pascal Vincent. Representation learning:
A review and new perspectives, 2012.
[3] Harry Blum et al. A transformation for extracting new descriptors of shape.
Models for the perception of speech and visual form, 19(5):362–380, 1967.
[6] Dan Ciresan, Alessandro Giusti, Luca M. Gambardella, and Jürgen Schmid-
huber. Deep neural networks segment neuronal membranes in electron mi-
croscopy images. In F. Pereira, C.J.C. Burges, L. Bottou, and K.Q. Weinberg-
er, editors, Advances in Neural Information Processing Systems 25, pages 2843–
2851. Curran Associates, Inc., 2012. URL http://papers.nips.cc/paper/
4741-deep-neural-networks-segment-neuronal-membranes-in-electron-microscop
pdf.
[8] E.W. Dijkstra. A note on two problems in connexion with graphs. Numerische
Mathematik, 1(1):269–271, 1959. ISSN 0029-599X. doi: 10.1007/BF01386390.
URL http://dx.doi.org/10.1007/BF01386390.
[10] Dong-Chen He and Li Wang. Texture unit, texture spectrum, and texture
analysis. Geoscience and Remote Sensing, IEEE Transactions on, 28(4):
509–512, 1990.
[11] Weijun He, Xiaoxu Wang, Dimitris Metaxas, Robin Mathew, and Eileen
White. Cell segmentation for division rate estimation in computerized video
time-lapse microscopy. In Biomedical Optics (BiOS) 2007, pages 643109–
643109. International Society for Optics and Photonics, 2007.
52
[12] J. Hilditch. Linear skeletons from square cupboards. Machine Intelligence, 4:
404–420, 1969.
[15] George H. Joblove and Donald Greenberg. Color spaces for computer graphics.
SIGGRAPH Comput. Graph., 12(3):20–25, August 1978. ISSN 0097-8930.
doi: 10.1145/965139.807362. URL http://doi.acm.org/10.1145/965139.
807362.
[16] Michael Kass, Andrew Witkin, and Demetri Terzopoulos. Snakes: Active
contour models. International journal of computer vision, 1(4):321–331, 1988.
[18] Kang Li, Eric D Miller, Mei Chen, Takeo Kanade, Lee E Weiss, and Phil G
Campbell. Cell population tracking and lineage construction with spatiotem-
poral context. Medical image analysis, 12(5):546–566, 2008.
[19] WarrenS. McCulloch and Walter Pitts. A logical calculus of the ideas
immanent in nervous activity. The bulletin of mathematical biophysics,
5(4):115–133, 1943. ISSN 0007-4985. doi: 10.1007/BF02478259. URL
http://dx.doi.org/10.1007/BF02478259.
[21] J. Pan, T. Kanade, and Mei Chen. Heterogeneous conditional random field:
Realizing joint detection and segmentation of cell regions in microscopic
images. In Computer Vision and Pattern Recognition (CVPR), 2010 IEEE
Conference on, pages 2940–2947, June 2010. doi: 10.1109/CVPR.2010.
5540037.
[22] Robert E. Schapire and Yoram Singer. Improved boosting algorithms using
confidence-rated predictions. In Machine Learning, pages 80–91, 1999.
[23] Jindřich Soukup, Petr Cı́sař, and Filip Šroubek. Segmentation of time-lapse
images with focus on microscopic images of cells. In Alfredo Petrosino,
editor, Image Analysis and Processing – ICIAP 2013, volume 8157 of Lecture
Notes in Computer Science, pages 71–80. Springer Berlin Heidelberg, 2013.
ISBN 978-3-642-41183-0. doi: 10.1007/978-3-642-41184-7 8. URL http:
//dx.doi.org/10.1007/978-3-642-41184-7_8.
53
[24] Zhaozheng Yin and Takeo Kanade. Restoring artifact-free microscopy im-
age sequences. In Biomedical Imaging: From Nano to Macro, 2011 IEEE
International Symposium on, pages 909–913. IEEE, 2011.
[25] F. Zernike. Phase contrast, a new method for the microscopic observa-
tion of transparent objects. Physica, 9:686–698, July 1942. doi: 10.1016/
S0031-8914(42)80035-X.
54
List of Figures
1 Snapshots from some series . . . . . . . . . . . . . . . . . . . . . . 3
2 An example of segmentation . . . . . . . . . . . . . . . . . . . . . 3
3 An illustration of computing (f ∗ g)(x). The value of the functions
are 0 outside the lines denoting their values. . . . . . . . . . . . . 9
4 Examples of the Gaussian convolution core. . . . . . . . . . . . . 10
5 Blurring a gray-scale image with the Gaussian core. . . . . . . . . 11
6 A part of an image before and after thresholding using Otsu’s method. 12
7 An example of the results of two different skeletonization algorithms.
The pattern is gray, its skeleton is white. . . . . . . . . . . . . . . 13
8 A demonstration of the watershed algorithm. . . . . . . . . . . . . 14
6.1 A comparison of the Gaussian cores used for our method and for
the watershed method. . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2 A comparison of the results our method and the watershed method. 48
6.3 A graphical comparison of the results of the two methods. . . . . 49
55
7.2 Our method: dist . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.3 Our method: cover . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.4 Our method: steps . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.5 Our method: diameter . . . . . . . . . . . . . . . . . . . . . . . 60
7.6 Our method: variance . . . . . . . . . . . . . . . . . . . . . . . . 61
7.7 Our method: angle . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.8 Our method: distance . . . . . . . . . . . . . . . . . . . . . . . . 62
7.9 Our method: circularity . . . . . . . . . . . . . . . . . . . . . . 62
7.10 The watershed: diameter . . . . . . . . . . . . . . . . . . . . . . 63
7.11 The watershed: variance . . . . . . . . . . . . . . . . . . . . . . 63
56
Attachments
A - CD
The attached CD contains:
• An installation manual together with all files needed for the installation.
• A user manual for the whole GUI, together with the minimum requirements
of the program.
• All source files - (MATLAB: .fig, .mat, Java: .class) needed for the com-
pilation of the program. Note that deploytool by MATLAB is needed to
compile the MATLAB files.
57
B - The graphs justifying the values of
the parameters
The following graphs show how the value of the mean f-score and its deviation
change, when we shift the value of a single parameter at a time.
58
Figure 7.2 Our method: dist
59
Figure 7.4 Our method: steps
60
Figure 7.6 Our method: variance
61
Figure 7.8 Our method: distance
62
Figure 7.10 The watershed: diameter
63