### Segmentation

Image segmentation covers techniques for splitting one image in several homogeneous regions. The Segmenter interface implements methods to segment a raster. The available methods in TerraLib are:

- Region Growing: Creates regions by merging similar neighboring pixels. To reduce processing time, the raster is divided into pieces, and such pieces are segmented individually.

- Based on Baatz and Shape: Creates regions by merging similar neighboring pixels. The resultant regions must fit a predefined scale and compactness, provided by the user.

Input:

- One Raster,
- A vector of bands indices used to perform segmentation.

Output:

- One Raster with a single band, where the pixel value stands for the index of the region to which it belongs.

It is accessible through:
Raster Processing > Segmenter... (list of all raster layers)
This wizard consists of the following steps:

#### Wizard Page 1 - Selection of the layer with the desired raster (Layer Search)

1. On the List of Layers select the raster layer to apply the segmentation.
2. Optionally use Filter By Name field giving part of the layer name to help find the layer in the list.
3. Press Next to go to next step or Cancel to close the dialog.

#### Wizard Page 2 - Segmentation interface

1. Type - Choose the method of segmentation and set the specific parameters required.

- Region Growing

- Minimum segment size: A positive minimum segment size (pixels number ).
- Similarity Threshold: Use lower values to merge only those segments that are more similar - Higher values will allow more segments to be merged - valid values range: positive values - default: 0.1.

- Baatz

- Minimum segment size: A positive minimum segment size (pixels number ).
- Similarity Threshold: Use lower values to merge only those segments that are more similar - Higher values will allow more segments to be merged - valid values range: positive values - default: 0.1.
- Color Weight: The weight given to the color component, default: 0.75, valid range: [0,1].
- Compactness Weight: The weight given to the compactness component, default : 0.5, valid range: [0,1].

2. Select the Input Bands to be segmented by checking its box. For Baatz method, its is also possible to change Weight (The weight given to each band (note: the bands weights sum must always be 1) or an empty vector indicating that all bands have the same weight.)
3. Preview - optionally click on to check the segmentation of a small box of the image.
4. Press Next to go to next step, Back to check the previous wizard page or Cancel to close the dialog.

#### Wizard Page 3 - Segmentation Advanced parameters interface.

Optionally, use this page to change default values of advanced parameters related with performance.

1. Block options:

- Enable block processing: If checked, the original raster will be split into small blocks, each one will be segmented independently and the result will be merged (if possible) at the end.
- Enable block merging: If checked, a block merging procedure will be performed

2. Thread options:

- Maximum block size: The input image will be split into blocks with this width for processing, this parameter tells the maximum block lateral size (width or height). The default behavior, the size will be defined following the current system resources and physical processors number.
- Maximum threads number: The maximum number of concurrent threads. The default behavior is: automatically found.

#### Wizard Page 4 - Output Raster information

1. Raster Info - First press and inform the folder where the resulting file will be saved.
2. Name - inform the raster name.
3. Extra Parameters - if there are some, see the details on how to inform then here.
4. Press Finish to save the resulting segmented raster or Back to go to the previous wizard page.