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

End points, curve points and junction points of a binary image. More...

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

Go to the source code of this file.

Functions

p26_status p26_end_points (const p26_image *binary, int connectivity, p26_image **out)
 Selects the end points: the object points with exactly 1 object neighbor in the chosen connectivity (Pink's lptend).
p26_status p26_curve_points (const p26_image *binary, int connectivity, p26_image **out)
 Selects the curve points: the object points p with T(p) = 2 and exactly 2 object neighbors in the chosen connectivity (Pink's lptcurve).
p26_status p26_junction_points (const p26_image *binary, int connectivity, p26_image **out)
 Selects the junction points: the object points with at least 3 object neighbors in the chosen connectivity (Pink's lptjunction).

Detailed Description

End points, curve points and junction points of a binary image.

These three selectors read the shape of a thin object, such as a skeleton (pink26/skeleton.h, pink26/parallel_skeleton.h): where its branches end, where it is a simple curve, and where several branches meet. They are Pink's point selectors (lseltopo.c), unchanged. Each one looks only at the object neighbors of a point, in the chosen connectivity n: the 4 or 8 neighbors in 2D, the 6 or 26 neighbors in 3D.

Definitions (Pink's, in plain words), for an object point p:

  • end point: p has exactly 1 object neighbor;
  • curve point: T(p) = 2 and p has exactly 2 object neighbors. T(p) is the topological number of pink26/topology.h: the number of object components around p. With n = 8 or 26, the counted neighbors are all the points around p, so this means that each of the two components around p is a single point: p sits between exactly two points of a thin curve. With n = 4 or 6, only the 4 (or 6) closest neighbors are counted, while T(p) also looks at the diagonal points: a component may hold a diagonal point as well. Example (2D, n = 4): the points of row 2, columns 1 to 3, plus the diagonal point at row 1, column 3. The point (row 2, column 2) has 2 object 4-neighbors and T = 2: it is a 4-curve point. It has 3 object 8-neighbors: it is not an 8-curve point;
  • junction point: p has at least 3 object neighbors. A point may be none of the three: an isolated point (no object neighbor), or a point whose 2 object neighbors touch each other (T = 1, the corner of a staircase with n = 8, which a thinning removes).

Two meanings of "junction". Here a junction only counts neighbors. That count makes sense on a thin skeleton only: on a thick object nearly every point is a junction in this sense (in a full 3 x 3 square, with n = 8, all 9 points are: a corner has 3 object neighbors, a side point 5, the center 8). Even on a thin skeleton, the meeting point of branches can count several junction points: with n = 8, when two branches leave it through two sides of the pixel (4-neighbors) that share a corner, their first points touch each other by a corner and have 3 object neighbors too. The classification of Malandain, Bertrand and Ayache (p26_point_classes_3d() in pink26/topology.h) reads a junction on the topological numbers T and T-bar instead: it is a topological notion, which holds on thick objects as well as on thin ones.

Border convention: as everywhere in pink26, the image is surrounded by an infinite background, so a point on the side of the image is selected like any other point (a line that crosses the image has its two extreme points as end points). Pink's selectors never select a point of the border of their image: pink26 gives them a copy with a frame of 1 pixel of background on each side, along z too in 3D. A 3D image of a single plane, of shape (1, H, W), is therefore a 3D object one voxel thick.

Pink functions used (lseltopo.c; Couprie, ESIEE). The neighbor counts are nbvois4 / nbvois8 (mctopo.c) and mctopo3d_nbvoiso6 / mctopo3d_nbvoiso26 (mctopo3d.c):

pink26 function       Pink         2D (n = 4 / 8)    3D (n = 6 / 26)
p26_end_points()      lptend       count = 1         count = 1
p26_curve_points()    lptcurve     curve4 / curve8   mctopo3d_curve6 /
                                                      mctopo3d_curve26
p26_junction_points() lptjunction  count >= 3        count >= 3

curve4, curve8, mctopo3d_curve6 and mctopo3d_curve26 compute T with top4, top8, mctopo3d_T6 and mctopo3d_T26: the T of p26_topological_numbers().

Sizes: Pink indexes the pixels in int64 (index_t), so the only limits are those of p26_image and of the framed copy (P26_E_OVERFLOW if the image with its frame of 1 pixel has more than PTRDIFF_MAX pixels).

Function Documentation

◆ p26_end_points()

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

Selects the end points: the object points with exactly 1 object neighbor in the chosen connectivity (Pink's lptend).

Parameters
binaryP26_U8 image, 2D or 3D; 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. It says which points are neighbors.
outSet to NULL on entry; receives a new P26_U8 image of the shape of binary, 1 on the selected points and 0 elsewhere (released with p26_image_free()).
Returns
P26_OK; P26_E_INVALID_ARG if out is NULL, binary is not a valid image, or connectivity is not a connectivity of the dimension; P26_E_UNSUPPORTED if connectivity is 18; P26_E_TYPE if binary is not P26_U8; P26_E_OVERFLOW if the image with its frame of 1 pixel has more than PTRDIFF_MAX pixels; P26_E_NOMEM if an allocation of pink26 fails; P26_E_INTERNAL if an allocation inside Pink fails: its result buffer (message "malloc failed for RES" on stderr), or, for p26_curve_points() in 3D, its 3D tables (the admitted code aborts; the result buffer is then leaked). With the arguments checked before the call, no other failure of Pink is left. On error, *out stays NULL.

Complexity: O(N) time for N pixels; memory: the framed copy (1 byte per pixel), Pink's result buffer of the same size, and the output.

◆ p26_curve_points()

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

Selects the curve points: the object points p with T(p) = 2 and exactly 2 object neighbors in the chosen connectivity (Pink's lptcurve).

With 8 or 26, p lies between exactly two points of a thin curve; with 4 or 6, a diagonal point may join one of the two components (see the top of this file).

Parameters
binaryAs p26_end_points().
connectivityAs p26_end_points(); T(p) is computed for this connectivity of the object (pink26/topology.h).
outAs p26_end_points().
Returns
As p26_end_points().

Complexity: as p26_end_points().

◆ p26_junction_points()

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

Selects the junction points: the object points with at least 3 object neighbors in the chosen connectivity (Pink's lptjunction).

This only counts neighbors: it describes a thin skeleton, not a thick object, where nearly every point has 3 neighbors or more. The topological junctions of [MBA93], read on T and T-bar, are the classes of p26_point_classes_3d() (pink26/topology.h); see "Two meanings of junction" at the top of this file.

Parameters
binaryAs p26_end_points().
connectivityAs p26_end_points().
outAs p26_end_points().
Returns
As p26_end_points().

Complexity: as p26_end_points().