# Segmentations

In this document, you will find all the Segmentations in Breeze with what parameters are available and example usage

## Model

##### Description

Select a PCA model to separate the background and the sample in the images.

##### Parameters

###### Model

Select a PCA model to remove unwanted parts of the image

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

###### Separate

One of the options below

**Normal**Can have both separated and combined objects.

**Separate adjacent objects**All objects are defined separately.

**Merge all objects into one**All objects are defined as one.

**Merge all objects per row**All objects per row segmentation are defined as one.

**Merge all objects per column**All objects per column segmentation are defined as one.

###### Type

One of the options below

**Sample**Includes the sample specified from the PCA.

**Background**Includes the opposite of the sample specified in the PCA.

## Model expression

##### Description

Segment objects from measurements using expressions and models.

##### Parameters

###### Expression

Write the expression for the segmentation, examples can be found below. The following comparators can be used for the expression:

And -

`&`

Or -

`|`

Less than -

`<`

Less or equal -

`<=`

Larger -

`>`

Larger or equal -

`>=`

Different from -

`!=`

###### Model

Select model to apply to the expression.

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

##### Example

###### Example 1

Segment object classified to sample class. **Expression:** `class = sample`

###### Example 2

Segment object not classified. **Expression: **`class != none`

###### Example 3

Indexing with 1 based index in band list. Expression `(B10 > 1.5 or B15 < 2) and B20 <=1.2)`

Band names can also be used instead of band numbers in the example the band names are HE and LE. `HE > 20 and LE <40`

###### Example 4

Using wavelength number. **Expression: **`(W980 > 1.5 or W1024 < 2) & W1200 <= 1.2`

## Constrained Spectral Unmixing

##### Description

Use the spectral information from pure samples in the *endmembers *to create objects from the expression criteria for segmentation.

##### Parameters

###### Expression

Write in the expression you want to apply. The following comparators can be used for the expression:

And -

`&`

Or -

`|`

Less than -

`<`

Less or equal -

`<=`

Larger -

`>`

Larger or equal -

`>=`

Different from -

`!=`

**Example: **`(Filename of end member 1) > 1 | (Filename of end member 2) < 0.5`

###### Method

Use one of the following regression methods to compare the end members spectrum to the measurements:

**None Negative Least Squares****Sum To One Least Squares**

###### Scatter correction

Select one of the options below

**None**No scatter correction applied.

**Baseline**A constant scatter correction is applied.

**Slope**A linear scatter correction is applied.

**Parabola**A quadratic scatter correction is applied.

###### Expression (Optional)

To include extra expression.

###### Range

Write in the wavelength range to use. If left empty all wavelengths are included.

###### End Members

Select files containing End members for each pure sample.

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

###### Separate

Select one of the options below

**Normal**Can have both separated and combined objects.

**Separate adjacent objects**All objects are defined separately.

**Merge all objects into one**All objects are defined as one.

**Merge all objects per row**All objects per row segmentation are defined as one.

**Merge all objects per column**All objects per column segmentation are defined as one.

## Grid and inset

##### Description

Create a grid on an object. Default settings create a 3x3 grid.

##### Parameters

###### Type

**Grid**Choose the size of the grid.

**Area**Choose the size of the grid element.

###### Insets

Choose which pixels are included in the grid.

###### Percent

**True**The insets take away a percentage of the image.

**False**The insets take away pixels instead of a percentage.

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

###### Separate

**Normal**Can have both separated and combined objects.

**Separate adjacent objects**All objects are defined separately.

**Merge all objects into one**All objects are defined as one.

**Merge all objects per row**All objects per row segmentation are defined as one.

**Merge all objects per column**All objects per column segmentation are defined as one.

## Horizontal interval

###### Description

Lets the user reduce the pixels horizontally in the images by creating an interval in which the pixels included are selected.

###### Parameters

###### Interval

States the pixels the user wants to include. (Edit lets the user look at which pixels are included)

## Intensity

##### Description

Segment objects from measurements using intensities in the different bands/wavelengths.

##### Parameters

###### Expression

Write expression. Band numbers are denoted `b[N]`

e.g. `b1`

and wavelengths are denoted `w[N]`

e.g. `w1`

. The following comparators can be used for the expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

Variable names that can be used in the expression:

`MinValue`

`MaxValue`

`AvarageValue`

`MinWavelengthValue`

`MaxWavelengthValue`

`AverageWavelengthValue`

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

###### Separate

**Normal**Can have both separated and combined objects.

**Separate adjacent objects**All objects are defined separately.

**Merge all objects into one**All objects are defined as one.

**Merge all objects per row**All objects per row segmentation are defined as one.

**Merge all objects per column**All objects per column segmentation are defined as one.

###### Pretreatments

Apply one or more pretreatments, see Pretreatments

##### Example

###### Using band numbers

**Expression: **`(b10 > 1.5 | b15 < 2) & b20 <= 1.2`

###### Using wavelengths.

**Expression: **`(w980 >1.5 | w1024 <2) & w1200 <=1.2`

###### Use variables for the expression.

**Expression: **`w980 > AvarageValue`

## Deep Learning image segmentation

##### Description

Object detection using pre-trained algorithms via ONNX. The object detection algorithms supported can be found under the parameter model type.

See ONNX image segmentation for more information.

##### Parameters

###### Model type

Faster R-CNN

YOLO v4

YOLO v5

###### Onnx file

Select the pre-trained ONNX file for the selected model type.

###### Confidence

The confidence level required by the model for an object to be categorized.

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

###### Separate

**Normal**Can have both separated and combined objects.

**Separate adjacent objects**All objects are defined separately.

**Merge all objects into one**All objects are defined as one.

**Merge all objects per row**All objects per row segmentation are defined as one.

**Merge all objects per column**All objects per column segmentation are defined as one.

##### Tips

In the analyze tree add the descriptor ”Segmentation label” and select a text file including the names of objects in the ONNX file.

## Manual selection in pixel explore

###### Description

To use manual selection in pixel explorer the user needs to select the (Pixel Explore) for a measurement.

The user selects a part of the measurement to include

Click on the (Add Sample(s) from selection) at the bottom of the wizard.

This makes it possible for the user to select and make their own objects from the measurement.

##### Parameters

###### Min area

The minimum number of pixels for an object to be included.

## Pixel class from external file

##### Description

Classify objects using pixel classification from external files.

##### Parameters

###### Category

Choose the category to which the external file should be applied.

###### File

Choose the file containing the pixel classification.

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

###### Separate

**Normal**Can have both separated and combined objects.

**Separate adjacent objects**All objects are defined separately.

**Merge all objects into one**All objects are defined as one.

**Merge all objects per row**All objects per row segmentation are defined as one.

**Merge all objects per column**All objects per column segmentation are defined as one.

## Pixel coordinates

##### Description

Lets the user create a specified region in the measurement based on pixel coordinates.

##### Parameters

###### Origo

**Upper left corner**Places the origo of the object created in the upper left corner.

**Parent object center**Places the origo of the object created in the center of the measurement.

**Parent object mass center**Places the origo of the created object at the mass center of the measurement.

###### Coordinate

State the coordinate of the object the user desire to build.

**Example: ** `0,0; 50,0; 50,50; 0,50`

creates a square with the side length of 50 pixels.

###### Center

**True**Place the center of the created object at the selected origo.

**False**Place the (0,0) coordinate at the selected origo.

## Python script

##### Description

Segmentation of measurement using an external python script.

See Python script for more information.

##### Parameters

###### Python file

Select python file.

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

###### Separate

**Normal**Can have both separated and combined objects.

**Separate adjacent objects**All objects are defined separately.

**Merge all objects into one**All objects are defined as one.

**Merge all objects per row**All objects per row segmentation are defined as one.

**Merge all objects per column**All objects per column segmentation are defined as one.

## Representative spectrum

##### Description

Takes the spectrum from x numbers of pixels to make representative spectrum. The pixels can be chosen in one out of five methods.

##### Parameters

###### Method

**Evenly spread**The pixels are evenly spread across the images/objects.

**Random**The pixels are randomly spread across the images/objects.

**Random(Gaussian)**The pixels are randomly spread with a larger concentration of pixels in the center of the images/objects.

**Spectral binning**The pixels are distributed using PCA to get a spread containing a variety of spectrums

**Spectral space filling**The pixels are distributed using PCA and iterated to find the spectrum containing the best variety to describe the spectrum of the objects.

**Spectral Clustering (k-means)**The pixels are distributed using k-means clustering to partition the pixels into

*k*number of clusters and select pixels for the partitioned clusters.

###### Number

Number of the representative spectrum.

###### Unique

**True**Adds only unique spectrum

**False**Can have the same spectrum from different representative spectrum pixels.

###### Clusters

Only applicable for **Spectral Clustering (k-means)**

Specify number of clusters (*k*) to partition the observations into.

## Shapefile

##### Description

Segment the image according to the specified shapefile which contains geospatial vector data according to Esri and GIS standard.

##### Parameters

###### Shape file

Select shape file to use for the shape inference. The accepted file extension is: `.shp`

in GIS format.

###### Point radius

If shape is a point, add some number of pixels as radius.

## Structure

##### Description

Select a band at which the segmentation should be applied.

##### Parameters

###### Band

Specify band number

###### Kernel

Select the kernel size (**Example:** `3x3`

or `5x5`

)

###### Threshold

Select the threshold to use for the objects to be included.

###### Min area

The minimum number of pixels for an object to be included.

###### Max area

The maximum number of pixels for an object to be included.

If 0 no maximum area is defined.

###### Object filter

Use an expression to further exclude unwanted objects based on shape.

Properties that can be used for the Expression:

`Area`

`Length`

`Width`

`Circumference`

`Regularity`

`Roundness`

`Angle`

`D1`

`D2`

`X`

`Y`

`MaxBorderDistance`

`BoundingBoxArea`

###### Shrink

Takes away x numbers of pixels at the borders of the objects included in images.

###### Separate

**Normal**Can have both separated and combined objects.

**Separate adjacent objects**All objects are defined separately.

**Merge all objects into one**All objects are defined as one.

**Merge all objects per row**All objects per row segmentation are defined as one.

**Merge all objects per column**All objects per column segmentation are defined as one.