**Name**

**one_levelset** Get boundaries of level set, using a simplified merging criterion in the 'well-known' segmentation algorithm

**Command Synopsis**

**one_levelset** [-l *level*] [-b *boundary*] [-p *polygons*] [-G *f_levelset*] [-B *b_levelset*] *fimage*

-llevel: pixels < =`level' (float) belong to the level set, default 127

-bboundary: output boundary of levelset, file cimage formated

-ppolygons: output boundary of levelset, file fpolygons formated

-Gf_levelset: output levelset with gray-`level', file fimage formated

-Bb_levelset: output levelset b/w, file cimage formated

fimage: original image

**Function Summary**

void one_levelset (level , cb , pb , fu , cu , image_org )

float *level ;

Cimage cb , cu ;

Fpolygons pb ;

Fimage fu ;

Fimage image_org ;

**Description**

This function generates a level set out of *fimage*. More precisely
the program segments the original image into two classes of regions.
First the regions which have gray level lower or equal than *level*,
the other regions are those with gray level above *level*.

In this application we consider the level set *L* to be given by

Different possibilities to view the result are given. Either one wants
the boundary of the level set, the **-b** option draws the boundary set
in a `cimage` *boundary* and **-p** writes the coordinates of the
contours into `fpolygons` *polygons*. Or one wants an image
of the level set, then with **-B** we obtain a black and white picture
(the pixels of *L* being black) and with **-G** the pixels of *L* will
be drawn in color
sup{*g*(*x*, *y*) / (*x*, *y*) *L*} and the other pixels
will be in color
sup{*g*(*x*, *y*) / (*x*, *y*) *L*}. For example you
want the *f_levelset* for *level*=127 of an image which has only
gray values 0,20,50,100,200 and 220. Then the set *L* will be drawn with
gray 100 and the other pixels with gray 220.

Notice that *L* is made of
disjoined (in the 4-neighborhood sense) connected sets
which thus have __closed__ Jordan curves as boundaries.

Let us give some more details about the **-p** option. The file *polygons*
will be in the `MW2`-format `fpolygons`. The coordinates of the
boundary are `floats` as they always have a decimal part of 0.5 .
In figure 3 we represent a image where
the pixels are represented by squares (white or gray). The level set
(gray squares) is bounded by its border, the black dots () which are
drawn are the points you will find in the `fpolygons` structure,
the coordinates can be read on the axes drawn above and besides the ``pixels''.

Each `fpolygon` has two channels of
information, the first is the *level*, the second is a signed label.
This label (`int`) shows which contours belong to the same set, if the
label is positive the current contour is the `outer' boundary of the set
(thus it is unique),
if the label is negative the current contour is `inside' the set (it is
a hole). For example the image of figure 3 will
yield one `fpolygon` labeled 1 with 14 points and one `fpolygon`,
labeled -1, made out of 4 points only.

The contour is oriented (the pixels are ordered)
such that the set is always on the __left__
if you follow the list of points.

For example lets say that the result in *polygons* is made
out of 5 `fpolygon` elements with labels 1,-1,2,-2,-2. This
means that there are 2 connected sets which compose *L*, one having
one hole the other one two. There is no information available
whether set 1 is in a hole of set 2, or set 2 in the hole of set 1, or if
both sets are completely apart.

Notice that if a set has just negative labeled contours then it is the background (as the image boundary is not coded).

Currently there are a ``few'' restrictions for the use of the **-p** option.
The result of the segmentation should just contain regions which
have only boundaries made out of one (1!) connected component. Also
should a set of *L* either be the background or not touch at all the
boundary of the image. If one of these cases occurs the program will exit
the construction of the *polygons* file.

**Version 1.01**

Last Modification date : Thu Nov 29 20:23:56 2001

**Author**

Georges Koepfler