Wiki

Version 43 (Annamaria Kiss, 30/05/2017 15:29)

1 35 Annamaria Kiss
2 1 Annamaria Kiss
3 43 Annamaria Kiss
h1. Table of Contents
4 43 Annamaria Kiss
{{TOC}}
5 1 Annamaria Kiss
6 43 Annamaria Kiss
h1. The Level Set Method (LSM)
7 6 Annamaria Kiss
8 30 Annamaria Kiss
The main idea of the level set method in image segmentation is to evolve a contour until it fits a desired object in the image. A  level set function (LSF) is defined on the image (one value per pixel), and the contour is defined as it's zero crossing points. The function is positive inside the contour and negative outside of it. At each time step, the values of the LSF are updated in each pixel, and thus the zero crossing points change and the contour evolves. The LSF's evolution is such that an energy is minimized, which in turn is usually based on the image properties (gradient, intensity...) and the geometrical aspects of the contour (curvature, size...).
9 6 Annamaria Kiss
10 6 Annamaria Kiss
11 26 Annamaria Kiss
h2. lsm_contour --> detects the outer surface of the tissue 
12 6 Annamaria Kiss
13 1 Annamaria Kiss
14 31 Annamaria Kiss
!>lsm_contour_100.png!The LSF is initialized with a linear threshold, which roughly separates the background from the cells. The threshold is linear in order to adjust for the image intensity variation along the z-axis. The function takes +c0 values inside the initial contour and -c0 outside, the area in the contour being the background. The contour evolves attracted mainly by the maximum gradient, corresponding to the edge of the cell walls. There are also a curvature term, to obtain a smoother contour, and an accelerating area term to push the contour towards the boundaries. At each time step, the background growth is measured. The algorithm stops when the growth stays in a small interval near zero for ten consecutive iterations.
15 23 Annamaria Kiss
16 10 Annamaria Kiss
h3. Usage
17 10 Annamaria Kiss
18 10 Annamaria Kiss
In order to check the syntax, just lounch the binary without any argument. It will give as output
19 22 Annamaria Kiss
<pre>
20 29 Annamaria Kiss
Usage : lsm_contour img t_up t_down a b smooth perUp perDown
21 6 Annamaria Kiss
Examples for parameter values:
22 6 Annamaria Kiss
------------------------------
23 6 Annamaria Kiss
img : grayscale image of cells, (.inr or .inr.gz)
24 6 Annamaria Kiss
Upper threshold : t_up = 20
25 6 Annamaria Kiss
Down threshold : t_down = 5
26 6 Annamaria Kiss
Area term : a = 0 (0.5, 1)
27 6 Annamaria Kiss
Curvature term : b = 0 (1)
28 6 Annamaria Kiss
Gaussian filter : smooth = 1 (0, if image already filtered)
29 6 Annamaria Kiss
Stop criteria : the contour evolution is in [perDown,perUp] for 10 consecutive iterations
30 6 Annamaria Kiss
     perUp = 0.002, perDown = -0.002
31 6 Annamaria Kiss
</pre>
32 6 Annamaria Kiss
33 33 Annamaria Kiss
In order to test it on an image file "sample-stack.inr.gz", lounch the binary with parameters :
34 6 Annamaria Kiss
35 1 Annamaria Kiss
<pre>
36 33 Annamaria Kiss
lsm_contour sample-stack.inr.gz 20 10 0 0 1 0.002 -0.002
37 1 Annamaria Kiss
</pre>
38 1 Annamaria Kiss
39 33 Annamaria Kiss
The detected contour is in the directory "sample-stack_LSMcont20-10a0b0s1".
40 1 Annamaria Kiss
41 26 Annamaria Kiss
42 25 Annamaria Kiss
43 1 Annamaria Kiss
44 28 Annamaria Kiss
h2. lsm_cells --> for cellular segmentation or nuclei detection
45 1 Annamaria Kiss
46 27 Annamaria Kiss
!>lsm_cells_100.png!The detection of cell-shapes is done in 3 steps :
47 15 Annamaria Kiss
- eroding the watershed segmentation and initialize a function for each cell
48 15 Annamaria Kiss
- evolve independently each cell's contour, attract by the maximal gradient (the inside edge of the cell walls)
49 15 Annamaria Kiss
- evolve simultaneously every cell's contour, attract by the maximal intensity (center of the cell walls)
50 12 Annamaria Kiss
In the last step, every cell evolves for one iteration and then possible overlap is checked. An overlap region is considered not segmented. A cell can't evolve in an other cell area : overlap can only happen in a same iteration. At each iteration, the growth of the segmented areas is measured, and the algorithm stops when this growth becomes null.
51 6 Annamaria Kiss
52 11 Annamaria Kiss
h3. Usage
53 6 Annamaria Kiss
54 11 Annamaria Kiss
You can recall the syntax any time by lounching the binary without any argument:
55 6 Annamaria Kiss
<pre>
56 6 Annamaria Kiss
Usage : lsm_cells img img_wat img_contour erosion [a b smooth lsm_type]
57 6 Annamaria Kiss
----------------- 
58 6 Annamaria Kiss
img : grayscale image of cells, (.inr or .inr.gz)
59 6 Annamaria Kiss
img_wat : image of seeds, (.inr or .inr.gz)
60 6 Annamaria Kiss
img_contour : mask, where cells do not evolve, (.inr or .inr.gz)
61 6 Annamaria Kiss
              if 'None', then cells can evolve on the whole image
62 6 Annamaria Kiss
erosion : amount of erosion of seeds for initialisation (uint8) --> -2, 0, 2
63 6 Annamaria Kiss
              if 0, then no erosion or dilation
64 6 Annamaria Kiss
              if negative, then a dilation is performed
65 6 Annamaria Kiss
a : area term (float) --> 0 or 0.5 or 1 (the default is 0.5)
66 6 Annamaria Kiss
              if negative, the object retracts
67 6 Annamaria Kiss
              if positive, the object inflates
68 6 Annamaria Kiss
b : curvature term (float) --> 0 or 1 (the default is 0)
69 6 Annamaria Kiss
gamma : scale parameter (float>0) --> 0.5 or 1 (the default is 1)
70 6 Annamaria Kiss
smooth : gaussian blur to apply to the image (int) --> 0 or 1 (the default is 0)
71 6 Annamaria Kiss
lsm_type : image, gradient or hessien based evolution --> 'i', 'g' or 'h' (the default is g)
72 6 Annamaria Kiss
</pre>
73 6 Annamaria Kiss
74 33 Annamaria Kiss
Applying it to the image "sample-stack.inr.gz" as the level sets are initialised by the watershed segmentation of the same image
75 1 Annamaria Kiss
<pre>
76 34 Annamaria Kiss
lsm_cells sample-stack.inr.gz sample-stack-watershed.inr.gz 'None' 2 0.3 0 0.2 1 'h'
77 32 Annamaria Kiss
</pre>
78 34 Annamaria Kiss
you will get the new segmentation in the "sample-stack-watershed_cellLSM-d2-a0.3-b0-g0.2-s1-h" folder. Or if you would like to use a mask image as background, you can make the test with the previously detected contour as a mask, like
79 32 Annamaria Kiss
<pre>
80 34 Annamaria Kiss
lsm_cells sample-stack.inr.gz sample-stack-watershed.inr.gz sample-stack_LSMcont20-10a0b0s1/sample-stack_LSMcont20-10a0b0s1.inr.gz 2 0.3 0 0.2 1 'h'
81 16 Annamaria Kiss
</pre>