**Name**

**ml_decompose** Compute all morpho_lines of an image

**Command Synopsis**

**ml_decompose** [-c *m_image_in*] [-o *ml_opt*] [-m] *image_in* *m_image*

-cm_image_in: original image in Mimage structure

-oml_opt: type of level lines: 0=upper (default), 1=lower, 2=iso

-m : optimize memory occupation (allows no free(points))

image_in: original image

m_image: mimage with all morpho_lines

**Function Summary**

Mimage ml_decompose (m_image_in , ml_opt , m_flag , image_in )

Mimage m_image_in ;

int *ml_opt ;

char *m_flag ;

Fimage image_in ;

**Description**

This module computes a decomposition of *image_in*
into `morpho_lines`. The algorithm is based on the
MW2 modules **fvalues** and **ml_extract**, it is recommended
to read first the description of these modules.

Let the set of pixel values in *image_in* be
{*v*_{0},..., *v*_{N}}, with
*v*_{i} < *v*_{i+1}.
Using option **-o** we have the following possibilities
for the decomposition:

- 0
- decompose into level lines such that
*v*_{i}*g*(*i*,*j*) (default) - 1
- decompose into level lines such that
*g*(*i*,*j*)*v*_{i} - 2
- decompose into isolines,
*g*(*i*,*j*) =*v*_{i}.

The **-m** flag allows to optimize memory occupation during
the decomposition. This is interesting if you use **ml_decompose**
on the UNIX command line. Using this flag in an internal call
of the module **ml_decompose()** and trying to delete
points separately in the sequel of your program will corrupt
the data structure.

The module will set the dimensions of *m_image*, to those
of *image_in*, the minvalue of *m_image* is set to *v*_{0}
and the maxvalue to *v*_{N}. At last, the `morpho_lines`
are created.

If the option **-c** is used, this information is set in the
`mimage` *m_image_in*, else a new `mimage` is created.
This option is useful if you have, for example, already an `mimage`
with its `morpho_sets` and you want to add the `morpho_lines`
into this structure (instead of creating a new `mimage` structure).

Let us discuss in more detail the different decompositions.

- 0
*image_in*is decomposed into level sets*L*_{i}= {(*i*,*j*) /*g*(*i*,*j*)*v*_{i}}, for*i*= 1,...,*N*. Notice that*L*_{0}=*image_in*. The list of`morpho_lines`is in__increasing__order: first all the`morpho_lines`for*v*_{1}, those then for*v*_{2}, and so on, up to*v*_{N}.- 1
*image_in*is decomposed into level sets*L*_{i}= {(*i*,*j*) /*g*(*i*,*j*)*v*_{i}}, for*i*= 0,...,*N*- 1. Notice here that*L*_{N}=*image_in*. The list of`morpho_lines`is in__decreasing__order: first all the`morpho_lines`for*v*_{N-1}, than those for*v*_{N-2}, and so on, down to*v*_{0}.- 2
*image_in*is decomposed into isosets*I*_{i}= {(*i*,*j*) /*g*(*i*,*j*) =*v*_{i}}, for*i*= 0,...,*N*. In this case the list of`morpho_lines`is in increasing order, from*v*_{0}up to*v*_{N}.

In case 0 and 1 the order in which the `morpho_lines` are listed
is essential to obtain a correct reconstruction by **ml_reconstruct**.
For isosets the order doesn't matter in the reconstruction.

This module is useful to compute a topographic map
of a gray levels
image [CCM96][CCM99].
However, since the Fast Level Sets Transform [MG00]
has been implemented, you would get faster computation by using flst-based modules
such as `flst`.

**See Also**

**Version 6.9**

Last Modification date : Fri Jan 25 13:17:23 2002

**Author**

Georges Koepfler