pink26 0.1.1
Image processing and digital topology for teaching
Loading...
Searching...
No Matches
topology.h File Reference

Topological numbers, simple points and point types of binary images. More...

#include <pink26/image.h>
#include <pink26/status.h>

Go to the source code of this file.

Enumerations

enum  p26_point_type {
  P26_POINT_BACKGROUND = 0 , P26_POINT_SIMPLE = 1 , P26_POINT_MULTIPLE = 2 , P26_POINT_SEPARATING = 3 ,
  P26_POINT_ISOLATED = 4 , P26_POINT_INTERIOR = 5 , P26_POINT_OTHER = 6
}
 Type of a point, as in Pink's typetopobin(). More...
enum  p26_point_class_3d {
  P26_CLASS_BACKGROUND = 0 , P26_CLASS_INTERIOR = 1 , P26_CLASS_ISOLATED = 2 , P26_CLASS_BORDER = 3 ,
  P26_CLASS_CURVE = 4 , P26_CLASS_CURVES_JUNCTION = 5 , P26_CLASS_SURFACE = 6 , P26_CLASS_SURFACE_CURVE_JUNCTION = 7 ,
  P26_CLASS_SURFACES_JUNCTION = 8 , P26_CLASS_SURFACES_CURVES_JUNCTION = 9
}
 Class of a 3D point in the topological classification of Malandain, Bertrand & Ayache [MBA93] (Table 1): what the object looks like around the point (a volume, a surface, a curve, or a junction of several of them). More...

Functions

p26_status p26_topological_numbers (const p26_image *binary, int connectivity, p26_image **t_out, p26_image **tbar_out)
 Computes the topological numbers T and T-bar of every point.
p26_status p26_simple_points (const p26_image *binary, int connectivity, p26_image **out)
 Marks the simple points of a binary image (Bertrand 1994).
p26_status p26_point_types (const p26_image *binary, int connectivity, p26_image **out)
 Classifies every point of a binary image (see p26_point_type).
p26_status p26_topological_numbers_at (const p26_image *binary, p26_index point, int connectivity, int *t, int *tbar)
 Computes T and T-bar at one point, without processing the whole image.
p26_status p26_point_classes_3d (const p26_image *binary, int connectivity, p26_image **out)
 Classifies every point of a 3D binary image as in [MBA93] Table 1 (see p26_point_class_3d).

Detailed Description

Topological numbers, simple points and point types of binary images.

Definitions (Bertrand 1994, "Simple points, topological numbers and geodesic neighborhoods in cubic grids", Pattern Recognition Letters 15(10); Couprie & Bertrand 2009, IEEE TPAMI 31(4)). X is the object, X-bar its complement, n the connectivity of the object; the background uses the complementary connectivity n-bar (4 <-> 8 in 2D, 6 <-> 26 in 3D). N*8, N*18 and N*26 are the 8-, 18- and 26-neighborhoods of p without p.

T(p, X) is the number of n-connected components of X ∩ N*(p) that are n-adjacent to p; the neighborhood N* depends on n:

2D: T4 and T8 use N*8 (4-components 4-adjacent to p for T4); 3D: T26 uses N*26 (26-components of X ∩ N*26(p)); T6 uses N*18 (6-components of X ∩ N*18(p) 6-adjacent to p). This is the geodesic neighborhood G6(p, X) of order 2 of Bertrand 1994: the corner voxels of N*26 do not count.

The topological number of the background, T-bar(p) = T-bar_n(p, X), is the number T_n-bar(p, X-bar) of X-bar with the complementary connectivity and the neighborhood rule above: for a 6-object it is T26 of X-bar (over N*26), for a 26-object it is T6 of X-bar (over N*18), for a 4-object T8 of X-bar and for an 8-object T4 of X-bar (both over N*8).

An object point is simple (its removal does not change the topology) iff T(p) = 1 and T-bar(p) = 1 (Bertrand 1994). Likewise, a background point with T(p) = T-bar(p) = 1 can be added to the object without changing the topology.

Border convention: every image is surrounded by an infinite background, so the points of the first and last rows, columns and planes have a complete neighborhood.

Enumeration Type Documentation

◆ p26_point_type

Type of a point, as in Pink's typetopobin().

The values 0 to 5 are Pink's constants (NONE or fond, SIMPLE, MULTIPLE, SEPARANT, ISOLE, INTERIEUR). The rules are applied in this order, with (T, T-bar) the topological numbers: background point -> BACKGROUND; (1, 1) -> SIMPLE; T > 2 -> MULTIPLE; T = 2 -> SEPARATING; T = 0 -> ISOLATED; T-bar = 0 -> INTERIOR; otherwise OTHER.

Enumerator
P26_POINT_BACKGROUND 

Not an object point.

P26_POINT_SIMPLE 

T = 1 and T-bar = 1.

P26_POINT_MULTIPLE 

T > 2.

P26_POINT_SEPARATING 

T = 2.

P26_POINT_ISOLATED 

T = 0.

P26_POINT_INTERIOR 

T-bar = 0.

P26_POINT_OTHER 

Object point matching none of the above, e.g.

a voxel of a one-voxel-thick surface (T = 1, T-bar = 2): removing it would pierce a hole through the surface (Bertrand & Malandain 1994, Pattern Recognition Letters 15(2)). Pink returns 0 for it, the code of the background: pink26 tells the two apart (documented deviation).

◆ p26_point_class_3d

Class of a 3D point in the topological classification of Malandain, Bertrand & Ayache [MBA93] (Table 1): what the object looks like around the point (a volume, a surface, a curve, or a junction of several of them).

Code 0 is the background; codes 1 to 9 follow types A to I of Table 1. The paper uses two numbers, C* and C-bar; they are the topological numbers of a 26-connected object: C* = T (26-components of the object in N*26) and C-bar = T-bar (6-components of the background in N*18 that are 6-adjacent to the point). The rules are applied in this order (A before B), and every pair (T, T-bar) gets a class: "there will not remain any unclassified point" ([MBA93] section 4.3).

Link with p26_point_type (same T and T-bar): BORDER is a simple point (P26_POINT_SIMPLE); INTERIOR and ISOLATED are the point types of the same name; SURFACE and SURFACES_JUNCTION (T = 1, T-bar >= 2) are P26_POINT_OTHER.

Two meanings of "junction". Here a junction is read on T and T-bar: it is a topological notion, which holds on thick objects as well as on surfaces and curves one voxel thick. The junction points of Pink's point selectors (p26_junction_points() in pink26/point_selection.h) only count neighbors: a point with at least 3 object neighbors. That count makes sense on a thin skeleton only; on a thick object nearly every point is a junction in that sense (all 27 points of a full 3 x 3 x 3 cube, none of which is a junction here: 26 are BORDER, the center INTERIOR).

The digital grid hides some junctions ([MBA93] section 5): the foot of a line planted perpendicularly on a flat plate is a BORDER point. T = 1, because the first voxel of the line touches the plate voxels around the foot. T-bar = 1, because the line voxel fills the only face neighbor above the foot, so no background voxel above the foot is 6-adjacent to it. With T = 1 and T-bar = 2 the point would be SURFACE.

[MBA93] G. Malandain, G. Bertrand, N. Ayache, "Topological segmentation of discrete surfaces", International Journal of Computer Vision 10(2), pp. 183-197, 1993.

Enumerator
P26_CLASS_BACKGROUND 

Not an object point.

P26_CLASS_INTERIOR 

Type A, interior point of a volume: T-bar = 0 (no background around it).

P26_CLASS_ISOLATED 

Type B, isolated point: T = 0 (no object neighbor).

P26_CLASS_BORDER 

Type C, border point, i.e.

a simple point: T-bar = 1 and T = 1.

P26_CLASS_CURVE 

Type D, curve point (removing it cuts the curve in two): T-bar = 1 and T = 2.

P26_CLASS_CURVES_JUNCTION 

Type E, junction of curves (3 or more branches): T-bar = 1 and T > 2.

P26_CLASS_SURFACE 

Type F, surface point (background on its two sides): T-bar = 2 and T = 1.

P26_CLASS_SURFACE_CURVE_JUNCTION 

Type G, junction of a surface and one or more curves: T-bar = 2 and T >= 2.

P26_CLASS_SURFACES_JUNCTION 

Type H, junction of surfaces (3 or more background parts): T-bar > 2 and T = 1.

P26_CLASS_SURFACES_CURVES_JUNCTION 

Type I, junction of surfaces and one or more curves: T-bar > 2 and T >= 2.

Function Documentation

◆ p26_topological_numbers()

p26_status p26_topological_numbers ( const p26_image * binary,
int connectivity,
p26_image ** t_out,
p26_image ** tbar_out )

Computes the topological numbers T and T-bar of every point.

Both numbers are computed for all points, object or background (Bertrand 1994: they only look at the neighbors of p).

Parameters
binaryP26_U8 image; any nonzero value is an object point.
connectivityConnectivity of the object: 4 or 8 for a 2D image, 6 or 26 for a 3D image (the background uses the complementary one).
t_outReceives a new P26_U8 image of the shape of binary holding T; owned by the caller (p26_image_free()).
tbar_outSame for T-bar.
Returns
P26_OK; P26_E_INVALID_ARG if an output pointer is NULL, binary is not a valid image, or connectivity does not match the dimension; P26_E_TYPE if binary is not P26_U8; P26_E_UNSUPPORTED if connectivity is 18; P26_E_OVERFLOW if the image with its one-pixel border is too large; P26_E_NOMEM if an allocation fails; P26_E_INTERNAL if the admitted Pink code aborted. On error, *t_out and *tbar_out are NULL.

Complexity: O(N) time for N pixels, 3 * N bytes of memory (one bordered copy of the input and the two outputs), no allocation per point.

◆ p26_simple_points()

p26_status p26_simple_points ( const p26_image * binary,
int connectivity,
p26_image ** out )

Marks the simple points of a binary image (Bertrand 1994).

Parameters
binaryP26_U8 image; any nonzero value is an object point.
connectivitySee p26_topological_numbers().
outReceives a new P26_U8 image of the shape of binary, 1 on the simple object points and 0 elsewhere; owned by the caller.
Returns
P26_OK, or the errors of p26_topological_numbers(). On error, *out is NULL.

Complexity: O(N) time, same memory as p26_topological_numbers().

◆ p26_point_types()

p26_status p26_point_types ( const p26_image * binary,
int connectivity,
p26_image ** out )

Classifies every point of a binary image (see p26_point_type).

Parameters
binaryP26_U8 image; any nonzero value is an object point.
connectivitySee p26_topological_numbers().
outReceives a new P26_U8 image of the shape of binary holding a p26_point_type per pixel; owned by the caller.
Returns
P26_OK, or the errors of p26_topological_numbers(). On error, *out is NULL.

Complexity: O(N) time, same memory as p26_topological_numbers().

◆ p26_topological_numbers_at()

p26_status p26_topological_numbers_at ( const p26_image * binary,
p26_index point,
int connectivity,
int * t,
int * tbar )

Computes T and T-bar at one point, without processing the whole image.

Only the neighborhood of the point is read; the cost is O(1).

Parameters
binaryP26_U8 image; any nonzero value is an object point.
pointIndex of the point, i = z * rs * cs + y * rs + x (0 <= i < number of pixels).
connectivitySee p26_topological_numbers().
tReceives T(point).
tbarReceives T-bar(point).
Returns
P26_OK; P26_E_INVALID_ARG if t or tbar is NULL, point is out of range, binary is not a valid image or connectivity does not match the dimension; P26_E_TYPE if binary is not P26_U8; P26_E_UNSUPPORTED if connectivity is 18; P26_E_INTERNAL if the admitted Pink code aborted. On error, *t and *tbar are left untouched.

◆ p26_point_classes_3d()

p26_status p26_point_classes_3d ( const p26_image * binary,
int connectivity,
p26_image ** out )

Classifies every point of a 3D binary image as in [MBA93] Table 1 (see p26_point_class_3d).

The classification is defined for a 26-connected object (6-connected background) in 3D, the case of the paper.

Parameters
binary3D P26_U8 image; any nonzero value is an object point. A 3D image of a single plane, of shape (1, H, W), is a plate one voxel thick.
connectivityConnectivity of the object: must be 26.
outReceives a new P26_U8 image of the shape of binary holding a p26_point_class_3d per voxel; owned by the caller (p26_image_free()).
Returns
P26_OK; P26_E_INVALID_ARG if out is NULL, binary is not a valid image, binary is a 2D image, or connectivity is not 6, 18 or 26; P26_E_TYPE if binary is not P26_U8; P26_E_UNSUPPORTED if connectivity is 6 or 18; P26_E_OVERFLOW, P26_E_NOMEM, P26_E_INTERNAL as p26_topological_numbers(). On error, *out is NULL.

Complexity: O(N) time, same memory as p26_topological_numbers().