Spatial morphological Binary Dilation filter

Spatial morphological Binary Dilation filter. See Wikipedia for general information.

The spatial morphological binary dilation filter expands or dilates regions of foreground or 1 pixels in a binary image. It is used for tasks such as noise removal, boundary enhancement, and image segmentation, providing a way to fill gaps, smooth out regions, and connect adjacent pixels or objects.

The filter operates by moving a structuring element across the image. The structuring element defines the neighborhood around each pixel that will be considered during the dilation operation.

For each pixel in the image, the dilation filter checks if any 1 pixels within the structuring element are present. If at least one 1 pixel is found, the filter sets the corresponding pixel in the output image as 1. Thus, the filter expands the regions of 1 pixels by including neighboring pixels within the defined neighborhood.

When applying this algorithm to continous image data, the input will be binarised.

Usage:

  1. Start the algorithm from the Processing Toolbox panel.

  2. Select the raster to process and modify the parameterization if necessary, then click run.

    ../../../../_images/binary_dilation_filter_interface.png
  3. Processed image in comparison to the original.

    ../../../../_images/binary_dilation_filter_result.png

Parameters

Raster layer [raster]

Raster layer to be processed band-wise.

Function [string]

Python code. See binary_closing, generate_binary_structure, iterate_structure for information on different parameters.

Default:

from scipy.ndimage import binary_dilation, generate_binary_structure, iterate_structure

structure = generate_binary_structure(rank=2, connectivity=1)
structure = iterate_structure(structure=structure, iterations=1)
function = lambda array: binary_dilation(array, structure=structure, iterations=1)

Outputs

Output raster layer [rasterDestination]

Raster file destination.

Command-line usage

>qgis_process help enmapbox:SpatialMorphologicalBinaryDilationFilter:

----------------
Arguments
----------------

raster: Raster layer
    Argument type:  raster
    Acceptable values:
            - Path to a raster layer
function: Function
    Default value:  from scipy.ndimage import binary_dilation, generate_binary_structure, iterate_structure

structure = generate_binary_structure(rank=2, connectivity=1)
structure = iterate_structure(structure=structure, iterations=1)
function = lambda array: binary_dilation(array, structure=structure, iterations=1)
    Argument type:  string
    Acceptable values:
            - String value
            - field:FIELD_NAME to use a data defined value taken from the FIELD_NAME field
            - expression:SOME EXPRESSION to use a data defined value calculated using a custom QGIS expression
outputRaster: Output raster layer
    Argument type:  rasterDestination
    Acceptable values:
            - Path for new raster layer

----------------
Outputs
----------------

outputRaster: <outputRaster>
    Output raster layer