Morphological filters — SciPy Filters for QGIS¶
Binary dilation, erosion, closing, and opening¶
- class scipy_filters.algs.scipy_morphological_algorithm.SciPyBinaryMorphologicalAlgorithm[source]¶
Binary morphological filters: dilation, erosion, closing, and opening. Calculated with binary_dilation, binary_erosion, binary_closing, binary_opening respectively from scipy.ndimage.
Note
No data cells within the filter radius are filled with 0.
Dimension Calculate for each band separately (2D) or use all bands as a 3D datacube and perform filter in 3D.
Note
bands will be the first axis of the datacube.
Dilation Set pixel to maximum value of neighborhood. Remaining shapes are larger, lines are thicker. Erosion Set pixel to minimum value of neighborhood. Remaining shapes are smaller, lines are thinner. Closing Perform dilation and then erosion. Fills small holes, large shapes are preserved. Opening Perform erosion and then dilation. Removes small shapes, large shapes are preserved.
Structure String representation of array. Must have 2 dimensions if dimension is set to 2D. Should have 3 dimensions if dimension is set to 3D, but a 2D array is also excepted (a new axis is added as first axis and the result is the same as calculating each band seperately). Examples can be loaded with the load button. For convenience (i.e. when calling from a script), the following shortcuts are accepted as well: “square”, “cross”, “cross3D”, “ball”, “cube”.
Origin Shift the origin (hotspot) of the filter.
Iterations Each step of filter is repeated this number of times. Border value Valute at border of output array, defaults to 0. Mask Optional mask layer.
Grey dilation, erosion, closing, and opening¶
- class scipy_filters.algs.scipy_morphological_algorithm.SciPyGreyMorphologicalAlgorithm[source]¶
Grey morphological filters: dilation, erosion, closing, and opening. Calculated for every band with grey_dilation, grey_erosion, gey_closing or grey_opening, respectively from scipy.ndimage.
Note
No data cells within the filter radius are filled with 0.
Dilation Set pixel to maximum value of neighborhood. Remaining shapes are larger, lines are thicker. Erosion Set pixel to minimum value of neighborhood. Remaining shapes are smaller, lines are thinner. Closing Perform dilation and then erosion. Fills small holes, large shapes are preserved. Opening Perform erosion and then dilation. Removes small shapes, large shapes are preserved.
Structure String representation of array. Must have 2 dimensions if dimension is set to 2D. Should have 3 dimensions if dimension is set to 3D, but a 2D array is also excepted (a new axis is added as first axis and the result is the same as calculating each band seperately). Examples can be loaded with the load button. For convenience (i.e. when calling from a script), the following shortcuts are accepted as well: “square”, “cross”, “cross3D”, “ball”, “cube”.
Origin Shift the origin (hotspot) of the filter.
Size Size of flat and full structuring element, optional if footprint or structure is provided. Border mode determines how input is extended around the edges: Reflect (input is extended by reflecting at the edge), Constant (fill around the edges with a constant value), Nearest (extend by replicating the nearest pixel), Mirror (extend by reflecting about the center of last pixel), Wrap (extend by wrapping around to the opposite edge). Footprint Positions of elements of a flat structuring element used for the filter (string representation of array, only used if checkbox is checked).
Fill holes¶
- class scipy_filters.algs.scipy_morphological_binary_fill_holes.SciPyBinaryFillHolesAlgorithm[source]¶
Fill holes in binary shapes by using binary dilations
Calculated with binary_fill_holes from scipy.ndimage.
Note
No data cells within the filter radius are filled with 0.
Dimension Calculate for each band separately (2D) or use all bands as a 3D datacube and perform filter in 3D.
Note
bands will be the first axis of the datacube.
Structure String representation of array. Must have 2 dimensions if dimension is set to 2D. Should have 3 dimensions if dimension is set to 3D, but a 2D array is also excepted (a new axis is added as first axis and the result is the same as calculating each band seperately). Examples can be loaded with the load button. For convenience (i.e. when calling from a script), the following shortcuts are accepted as well: “square”, “cross”, “cross3D”, “ball”, “cube”.
Hit or miss¶
- class scipy_filters.algs.scipy_binary_hit_miss.SciPyBinaryHitMissAlgorithm[source]¶
Preserves pixels whose neighbourhood matches structure1, but does not match the (disjoint) structure2. Calculated with binary_hit_or_miss from scipy.ndimage.
Note
No data cells within the filter radius are filled with 0.
Dimension Calculate for each band separately (2D) or use all bands as a 3D datacube and perform filter in 3D.
Note
bands will be the first axis of the datacube.
Structure 1 String representation of array. Structure 2 String representation of array, disjoint to structure 1. If no value is provided, the complementary of structure1 is taken.
Both structures must have 2 dimensions if dimension is set to 2D. Should have 3 dimensions if dimension is set to 3D, but a 2D array is also excepted (a new axis is added as first axis and the result is the same as calculating each band seperately).
Tophat or morphological gradient/Laplace¶
- class scipy_filters.algs.scipy_morphological_algorithm.SciPyTophatAlgorithm[source]¶
Morphological filters: black/white tophat, morphological gradient/laplace.
Calculated with black_tophat, white_tophat, morphological_radient or morphological_laplace, respectively from scipy.ndimage.
Note
No data cells within the filter radius are filled with 0.
Dimension Calculate for each band separately (2D) or use all bands as a 3D datacube and perform filter in 3D.
Note
bands will be the first axis of the datacube.
White tophat Difference between input raster and it’s opening. Extracts white spots smaller than the structural element. Black tophat Difference between input raster and it’s closing. Extracts black spots smaller than the structural element. Morphological gradient Difference between dilation and erosion. Morphological laplace Difference between internal and external gradient.
Structure String representation of array. Must have 2 dimensions if dimension is set to 2D. Should have 3 dimensions if dimension is set to 3D, but a 2D array is also excepted (a new axis is added as first axis and the result is the same as calculating each band seperately). Examples can be loaded with the load button. For convenience (i.e. when calling from a script), the following shortcuts are accepted as well: “square”, “cross”, “cross3D”, “ball”, “cube”.
Origin Shift the origin (hotspot) of the filter.
Size Size of flat and full structuring element, optional if footprint or structure is provided. Border mode determines how input is extended around the edges: Reflect (input is extended by reflecting at the edge), Constant (fill around the edges with a constant value), Nearest (extend by replicating the nearest pixel), Mirror (extend by reflecting about the center of last pixel), Wrap (extend by wrapping around to the opposite edge).
Footprint Positions of elements of a flat structuring element used for the filter (as string representation of array). Must have 2 dimensions if dimension is set to 2D. Should have 3 dimensions if dimension is set to 3D, but a 2D array is also excepted (a new axis is added as first axis and the result is the same as calculating each band seperately). Examples can be loaded with the load button. For convenience (i.e. when calling from a script), the following shortcuts are accepted as well: “square”, “cross”, “cross3D”, “ball”, “cube”.