![]() |
ImFusion C++ SDK 4.5.0
|
Set of functions for efficient connectivity analysis of binary or thresholded images. More...
Set of functions for efficient connectivity analysis of binary or thresholded images.
This namespace provides optimized implementations for identifying and labeling connected components in 2D and 3D images. Both CPU and GPU implementations are available for both 2D and 3D images.
Enumerations | |
| enum | Connectivity { CONNECT4_2D = 4 , CONNECT8_2D = 8 , CONNECT6_3D = 6 , CONNECT18_3D = 18 , CONNECT26_3D = 26 } |
| Connectivity types for 2D and 3D connected component analysis. More... | |
Functions | |
| template<typename T, typename S> | |
| int | computeConnectedComponents (const TypedImage< T > *inImage, TypedImage< S > *labelImage, Connectivity connectivity, int minComponentSize=-1, int maxNumberComponents=-1, T threshold=T(1), int maxComponentSize=-1, std::vector< size_t > *componentSizes=nullptr) |
| Compute connected components of the input image using a CPU-based implementation. | |
| template<typename S> | |
| int | computeConnectedComponents (GlImage *inImage, TypedImage< S > *labelImage, Connectivity connectivity, int minComponentSize=-1, int maxNumberComponents=-1, double threshold=1.0, int maxComponentSize=-1, std::vector< size_t > *componentSizes=nullptr) |
| Compute connected components of the input image using a GPU-accelerated implementation. | |
| template<typename T, typename S> | |
| int | hysteresisThresholding (TypedImage< T > *inImage, TypedImage< S > *labelImage, double lowThreshold, double highThreshold, Connectivity connectivity, int minComponentSize=-1, int maxNumberComponents=-1) |
Connectivity types for 2D and 3D connected component analysis.
Defines the neighborhood structure used to determine if pixels/voxels belong to the same component:
| int ImFusion::ConnectivityAnalysis::computeConnectedComponents | ( | const TypedImage< T > * | inImage, |
| TypedImage< S > * | labelImage, | ||
| Connectivity | connectivity, | ||
| int | minComponentSize = -1, | ||
| int | maxNumberComponents = -1, | ||
| T | threshold = T(1), | ||
| int | maxComponentSize = -1, | ||
| std::vector< size_t > * | componentSizes = nullptr ) |
Compute connected components of the input image using a CPU-based implementation.
Identifies and labels all connected components in the input image using an optimized union-find algorithm. All pixels with a value greater than or equal to the specified threshold are considered foreground and processed. Components can be filtered by size and total count. The resulting label image assigns each pixel a unique component ID (starting from 1), with larger components receiving lower IDs. Background pixels are labeled as 0.
| inImage | Input image to analyze, will not be modified |
| labelImage | Output image to store component labels; must have the same dimensions as the input image |
| connectivity | Type of connectivity to use (4 or 8 for 2D images, 6, 18, or 26 for 3D images) |
| minComponentSize | Minimum component size in pixels/voxels; components smaller than this will be removed (-1 = no filtering) |
| maxNumberComponents | Maximum number of components to keep, sorted by size (-1 = keep all) |
| threshold | Threshold value; pixels >= threshold are considered foreground |
| maxComponentSize | Maximum component size in pixels/voxels; components larger than this will be removed (-1 = no filtering) |
| componentSizes | Optional output vector to receive component sizes; index i contains the size of component label i+1 |
| int ImFusion::ConnectivityAnalysis::computeConnectedComponents | ( | GlImage * | inImage, |
| TypedImage< S > * | labelImage, | ||
| Connectivity | connectivity, | ||
| int | minComponentSize = -1, | ||
| int | maxNumberComponents = -1, | ||
| double | threshold = 1.0, | ||
| int | maxComponentSize = -1, | ||
| std::vector< size_t > * | componentSizes = nullptr ) |
Compute connected components of the input image using a GPU-accelerated implementation.
Identifies and labels all connected components in the input image using GPU compute shaders. All pixels with a value greater than or equal to the specified threshold are considered foreground and processed. Components can be filtered by size and total count. The resulting label image assigns each pixel a unique component ID (starting from 1), with larger components receiving lower IDs. Background pixels are labeled as 0. Note: The underlying algorithm is inherently hard to parallelize, so the GPU implementation might be slower than the CPU implementation for small images.
| inImage | GPU image to analyze; must be a valid GlImage with texture data |
| labelImage | Output image to store component labels; must have the same dimensions as the input image |
| connectivity | Type of connectivity to use (4 or 8 for 2D images, 6, 18, or 26 for 3D images) |
| minComponentSize | Minimum component size in pixels/voxels; components smaller than this will be removed (-1 = no filtering) |
| maxNumberComponents | Maximum number of components to keep, sorted by size (-1 = keep all) |
| threshold | Threshold value; pixels >= threshold are considered foreground |
| maxComponentSize | Maximum component size in pixels/voxels; components larger than this will be removed (-1 = no filtering) |
| componentSizes | Optional output vector to receive component sizes; index i contains the size of component label i+1 |
| int ImFusion::ConnectivityAnalysis::hysteresisThresholding | ( | TypedImage< T > * | inImage, |
| TypedImage< S > * | labelImage, | ||
| double | lowThreshold, | ||
| double | highThreshold, | ||
| Connectivity | connectivity, | ||
| int | minComponentSize = -1, | ||
| int | maxNumberComponents = -1 ) |