Loading [MathJax]/jax/input/TeX/config.js
PISM, A Parallel Ice Sheet Model 2.2.1-cd005eec8 committed by Constantine Khrulev on 2025-03-07
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
label_components.hh
Go to the documentation of this file.
1/* Copyright (C) 2019, 2023 PISM Authors
2 *
3 * This file is part of PISM.
4 *
5 * PISM is free software; you can redistribute it and/or modify it under the
6 * terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with PISM; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef PISM_LABEL_COMPONENTS_H
21#define PISM_LABEL_COMPONENTS_H
22
23namespace pism {
24
25namespace array {
26class Scalar;
27class Scalar1;
28} // namespace array
29
30namespace connected_components {
31
32/*!
33 * Label connected components in an `image`, modifying it "in place".
34 *
35 * The image is `nrows, ncols` in size. Positive values are treated as "foreground", zero
36 * or negative as "background".
37 *
38 * If `mark_isolated_components` is set, then label isolated patches with `1` and patches
39 * connected to values marked with `reachable` with zeros.
40 *
41 * If `mark_isolated_components` is *not* set, then assign a unique (consecutive) labels to each
42 * patch, starting with `first_label`.
43 */
44void label_serial(double *image, int nrows, int ncols, bool mark_isolated_components, int reachable,
45 int min_label);
46
47/*!
48 * Label connected components in a `mask`, modifying it "in place".
49 *
50 * See the comment for the other `label_serial` for meanings of `mark_isolated_components`
51 * and `reachable`.
52 *
53 * Copies data from `mask` to rank 0 and processes it there.
54 */
55void label_serial(array::Scalar &mask, bool mark_isolated_components, int reachable);
56
57/*!
58 * Label connected components in a `mask`, modifying it "in place".
59 *
60 * Each component is assigned a unique ID using consecutive integers starting from 1.
61 *
62 * The argument `mask` has to have ghosts since this algorithm uses a ghosted array:
63 * requiring a ghosted `mask` allows us to use `mask` for temporary storage.
64 *
65 * Note: ghosts of `mask` are not valid upon returning from this function.
66 */
67void label(array::Scalar1 &mask);
68
69/*!
70 * Label connected components *not* connected to areas marked with `reachable`.
71 *
72 * Patches not connected to `reachable` are filled with ones, the rest of the mask is set to zero.
73 *
74 * The argument `mask` has to have ghosts since this algorithm uses a ghosted array:
75 * requiring a ghosted `mask` allows us to use `mask` for temporary storage.
76 *
77 * Note: ghosts of `mask` are not valid upon returning from this function.
78 */
79void label_isolated(array::Scalar1 &mask, int reachable);
80
81} // end of namespace connected_components
82
83} // end of namespace pism
84
85#endif /* PISM_LABEL_COMPONENTS_H */
void label_isolated(array::Scalar1 &mask, int reachable)
void label_serial(double *image, int nrows, int ncols, bool mark_isolated_components, int reachable, int min_label)