label-components
PISM's connected component labeling code in a Python module
Science Score: 57.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 2 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.9%) to scientific vocabulary
Repository
PISM's connected component labeling code in a Python module
Basic Info
- Host: GitHub
- Owner: pism
- License: gpl-3.0
- Language: C++
- Default Branch: main
- Size: 27.3 KB
Statistics
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Python (Cython) module implementing the serial connected component labeling (CCL) algorithm used in PISM. In addition to labeling connected components, our implementation can perform one kind of connected component analysis (CCA) needed to identify icebergs, lakes, areas connected to the open ocean, etc.
The method implemented here is very similar to the one in He et al, 2010, but using 4-connectivity.[^1]
@Article{He2010,
author = {He, Lifeng and Chao, Yuyan and Suzuki, Kenji},
journal = {International Journal of Pattern Recognition and Artificial Intelligence},
title = {A run-based one-and-a-half-scan connected-component labeling algorithm},
year = {2010},
month = {jun},
number = {04},
pages = {557--579},
volume = {24},
doi = {10.1142/s0218001410008032},
publisher = {World Scientific},
}
Given a threshold A, all pixels with values greater than A are interpreted as "foreground" pixels.
For a pixel p(row,col), the four pixels p(row-1,col), p(row+1,col), p(row,col-1), p(row,col+1) are called 4-neighbors of p(row,col). Two foreground pixels u and v are 4-connected if there is a sequence of foreground pixels p[0] = u, ..., p[i], p[i+1], ..., p[n] = v such that p[i+1] is a 4-neighbor of p[i] for all i.
A 4-connected component is the maximum set of foreground pixels such that any two pixels in the set are 4-connected.
This implementation has two modes:
Given a threshold
Aand defining "foreground" pixels accordingly, assign unique consecutive integer labels to all 4-connected components in the input.Given thresholds
AandB(A < B), define "foreground" pixels accordingly. Let a foreground pixel be "marked" if its value is greater thanB. Label all foreground pixels not 4-connected to a "marked" pixel with1, the rest with0.
Run
python3 setup.py build_ext --inplace
to build this module "in place."
Unlike PISM's version, this code uses short int instead of double arrays to speed it up. See pism_label_components.label().
In addition to this, it also contains the helper function pism_label_components.update_max_depth() that (together with label()) can be used to estimate "ocean access depths" as in
L. Nicola, R. Reese, M. Kreuzer, T. Albrecht, and R. Winkelmann, "Oceanic gateways to Antarctic grounding lines – Impact of critical access depths on sub-shelf melt," EGUsphere, vol. 2023, pp. 1–30, 2023, doi: 10.5194/egusphere-2023-2583.
See max_depth.py. The function update_max_depth() would be just as easy to write in Python, but this version (in Cython) is significantly faster.
[^1]: There are so many variations of CCL algorithms that it's hard to find a citation that is a perfect fit.
Owner
- Name: Parallel Ice Sheet Model
- Login: pism
- Kind: organization
- Email: uaf-pism@alaska.edu
- Location: University of Alaska Fairbanks
- Website: https://www.pism.io/
- Twitter: PISM_model
- Repositories: 43
- Profile: https://github.com/pism
An open source, parallel, high-resolution ice sheet model
Citation (CITATION.cff)
# -*- mode: yaml -*-
cff-version: 1.2.0
title: "PISM's connected component labeling implementation"
message: "If you use this software, please cite it using the metadata from this file."
type: software
contact:
- email: uaf-pism@alaska.edu
name: "PISM developers at UAF"
authors:
- given-names: Constantine
family-names: Khrulev
email: ckhroulev@alaska.edu
affiliation: University of Alaska Fairbanks
orcid: 'https://orcid.org/0000-0003-2170-7454'
repository-code: 'https://github.com/pism/label-components/'
license: GPL-3.0-or-later