Tool for drawing an N-D Voronoi label matrix given a set of centroids.
You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
Voronoi Label N
Tool for drawing a Voronoi label matrix given a set of centroids. Creates an N-D Voronoi diagram label matrix from input centroid coordinates. May be used directly on pixel coordinate centroids, or used on arbitrary numeric coordinate centroids with args 2-4.
Two methods are available:
-
"coordinates"- uses a compute- and memory-intensive direct computation of nearest centroid to each element. Labels all elements, biased towards smaller valued labels when there is a tie. Complexity isO(M*N*P)whereMis the number of centroids,Nis the number of dimensions,Pis the number of elements in the output image. Suitable if Image Processing Toolbox is not available. -
"watershed"- uses a faster, less-memory-intensive computation using optimized image processing algorithmsbwdist()andwatershed(). Prefer this method if Image Processing Toolbox is available, it is about twice as fast.
Usage:
- Pixel coordinates, call with 1st arg only, or with 1st and 5th (args 2-4 empty arrays).
- Arbitrary coordinates, call with 2nd arg to give shape, 3rd to give origin and 4th to scale pixels/voxels.
% direct
labels = voronoi_labeln(centroids) % implied shape
labels = voronoi_labeln(centroids, shape) % explicit shape
labels = voronoi_labeln(centroids, shape, [], px_len) % scale
labels = voronoi_labeln(centroids, shape, origin, []) % translate
labels = voronoi_labeln(centroids, shape, origin, px_len) % both
% watershed
labels = voronoi_labels(centroids, [], [], [], "watershed")
labels = voronoi_labels(centroids, shape, [], [], "watershed")
% ... etc.Cite As
William Warriner (2026). Voronoi Label N dimensions (https://github.com/wwarriner/matlab_voronoi_labeln), GitHub. Retrieved .
Acknowledgements
Inspired by: createVoronoi(centroids,imageFilename), Convert Voronoi cells to region mask
General Information
- Version 1.0.1.1 (18.1 KB)
-
View License on GitHub
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
Versions that use the GitHub default branch cannot be downloaded
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.1.1 | Update title |
||
| 1.0.1 | Watershed now behaves identically to direct compute, and about twice as fast. |
||
| 1.0.0.1 | Added sample labelvolshow() image. |
||
| 1.0.0 |
