|
pink26 0.1.1
Image processing and digital topology for teaching
|
Parallel thinning of binary images: critical kernels and two classic 2D thinnings. More...
Go to the source code of this file.
Enumerations | |
| enum | p26_parallel_shape { P26_PARALLEL_ULTIMATE = 0 , P26_PARALLEL_CURVILINEAR = 1 , P26_PARALLEL_SURFACE = 2 } |
| What a critical-kernel thinning keeps (see the top of this file). More... | |
Functions | |
| p26_status | p26_parallel_skeleton (const p26_image *binary, int connectivity, p26_parallel_shape shape, int symmetric, int max_steps, const p26_image *inhibit, p26_image **out) |
| Parallel thinning based on critical kernels ([BC08], [BC14], [CB16]). | |
| p26_status | p26_zhang_wang_thinning (const p26_image *binary, int max_steps, p26_image **out) |
| Zhang-Wang parallel thinning (2D; Zhang and Wang 1988; Pink's lskelzhangwang). | |
| p26_status | p26_guo_hall_thinning (const p26_image *binary, int variant, int max_steps, p26_image **out) |
| Guo-Hall parallel thinning (2D; Guo and Hall 1992; Pink's lskelguohall). | |
Parallel thinning of binary images: critical kernels and two classic 2D thinnings.
Sequential thinning (pink26/skeleton.h) removes ONE simple point at a time, so each step obviously keeps the topology. A parallel thinning removes a whole SET of points in each step. Removing several simple points together can break the topology even when each of them is simple: the two pixels of a 2-pixel segment are both simple, removing both erases the segment. A parallel algorithm must therefore choose which simple points may go together.
Critical kernels (Bertrand 2007; [BC08] in 2D, [BC14] and [CB16] in 3D) answer that question. Seen as a cubical complex, the object is made of faces (squares, edges, vertices; in 3D cubes too). A face f is "essential" when it is exactly the intersection of the largest faces of the object that contain it; its "core" is made of the essential faces strictly inside f. An essential face is "regular" when its core is reducible (it can be shrunk to a point without changing its topology), "critical" otherwise; the critical kernel is the set of the critical faces. Bertrand's theorem: any set between the critical kernel and the object has the topology of the object. In terms of points: the simple points may all go together, except that every small "crucial" configuration of simple points (in 2D: two 4-adjacent pixels, two diagonal pixels, a 2 x 2 square, recognised by the masks of [BC08]; in 3D also the configurations around an edge or a vertex) must keep at least one of its points.
Symmetric or asymmetric. A symmetric algorithm keeps ALL the points of every crucial configuration. It treats in the same way two configurations that are images of each other by a symmetry of the grid (a rotation of 90 degrees, a mirror, in 3D a permutation of the axes), so its result should not depend on how the object is oriented; but it may keep a small core where a single point would do: a 2 x 6 bar keeps 2 to 4 pixels in its middle, not one, because no pixel is "the" middle. An asymmetric algorithm keeps ONE point of each crucial configuration, chosen by a fixed rule (the first in a fixed direction): it thins further, down to one point for a disk, and its result depends a little on the orientation.
Shapes of the result:
Classic thinnings (2D only): Zhang and Wang 1988 and Guo and Hall 1992 are fast fully parallel algorithms from the image-processing literature, defined by local conditions on the 8 neighbours of a pixel, not by critical kernels. Pink states that Zhang-Wang is not topologically sound, and the Guo-Hall variants are not proved sound either: they may disconnect an object or remove a component. They are given for comparison in practical work; the critical-kernel algorithms are the ones with a proof.
What pink26 corrects in Pink's 3D functions (read this before comparing with Pink's commands skel_MK3, skel_AMK, skel_CK3a, skel_ACK3a, skel_SK3). The 2D functions are Pink's code unchanged: pink26 gives exactly Pink's results, and these kept the topology and the symmetries on every image tested. The five 3D functions had three defects, proved on the frozen original Pink (tests/oracle) and corrected in pink26 by marked edits of src/legacy/lskelpar3d.c ("pink26: fix"):
Connectivity: all these algorithms are written for an 8-connected object in 2D and a 26-connected object in 3D (background 4 / 6).
Border convention: as everywhere in pink26, the image is surrounded by an infinite background. pink26 gives Pink a copy with a frame of 2 pixels of background (Zhang-Wang and Guo-Hall look 2 pixels away), so an object that touches the side of the image is thinned as if the outside were background.
Pink functions used (lskelpar.c, lskelpar3d.c; Couprie, ESIEE):
shape symmetric 2D (object 8) 3D (object 26, corrected) ULTIMATE yes lskelMK2 [BC08] lskelMK3 (see below) ULTIMATE no lskelNK2b [BC08] lskelAMK3 [CB16] CURVILINEAR yes lskelCK2 lskelCK3a [BC14] CURVILINEAR no (none) lskelACK3a [CB16] SURFACE yes (no meaning in 2D) lskelSK3 [BC14] SURFACE no (no meaning in 2D) (none) Zhang-Wang lskelzhangwang Guo-Hall lskelguohall, variants 1, 2, 3
lskelMK3: Pink describes it as a version "revised after the IWCIA 2006 paper" ("révisée d'après le papier IWCIA 2006"), i.e. [BC06b] (a 2D paper, whose scheme the 3D functions extend); its 3D masks are those of [BC06] and [BC14].
References: [BC08] G. Bertrand, M. Couprie, "Two-dimensional parallel thinning algorithms based on critical kernels", Journal of Mathematical Imaging and Vision 31(1), 2008, pp. 35-56. [BC06] G. Bertrand, M. Couprie, "A new 3D parallel thinning scheme based on critical kernels", DGCI 2006, LNCS 4245, Springer, 2006, pp. 580-591. [BC06b] G. Bertrand, M. Couprie, "New 2D parallel thinning algorithms based on critical kernels", Combinatorial Image Analysis (IWCIA 2006), LNCS 4040, Springer, 2006, pp. 45-59 (as cited in M. Couprie, A. Saude, G. Bertrand, SIBGRAPI 2006, ref. [3]). [BC14] G. Bertrand, M. Couprie, "Powerful parallel and symmetric 3D thinning schemes based on critical kernels", Journal of Mathematical Imaging and Vision 48(1), 2014, pp. 134-148. [CB16] M. Couprie, G. Bertrand, "Asymmetric parallel 3D thinning scheme and algorithms based on isthmuses", Pattern Recognition Letters 76, 2016, pp. 22-31. G. Bertrand, "On critical kernels", Comptes Rendus Mathematique 345(7), 2007, pp. 363-367. Y. Y. Zhang, P. S. P. Wang, "A modified parallel thinning algorithm", Proc. 9th International Conference on Pattern Recognition, 1988, pp. 1023-1025. Z. Guo, R. W. Hall, "Fast fully parallel thinning algorithms", CVGIP: Image Understanding 55(3), 1992, pp. 317-328.
| enum p26_parallel_shape |
| p26_status p26_parallel_skeleton | ( | const p26_image * | binary, |
| int | connectivity, | ||
| p26_parallel_shape | shape, | ||
| int | symmetric, | ||
| int | max_steps, | ||
| const p26_image * | inhibit, | ||
| p26_image ** | out ) |
Parallel thinning based on critical kernels ([BC08], [BC14], [CB16]).
Each step removes, all at once, the simple points outside inhibit that are not needed to keep the topology (the crucial configurations, see the top of this file) and, for the curvilinear and surface shapes, that are not isthmuses. The result is a subset of the input with exactly its topology (same components, holes; in 3D cavities and tunnels). In 3D, pink26 corrects Pink's functions for this (see "What pink26 corrects" at the top of this file).
| binary | P26_U8 image, 2D or 3D; any nonzero value is an object point. |
| connectivity | Connectivity of the object: 8 in 2D, 26 in 3D (the background has 4 / 6). |
| shape | P26_PARALLEL_ULTIMATE, P26_PARALLEL_CURVILINEAR, or P26_PARALLEL_SURFACE (3D only). |
| symmetric | 1 for the symmetric algorithm, 0 for the asymmetric one (see the top of this file). |
| max_steps | Number of parallel steps: any negative value runs until no point changes; 0 returns a 0/1 copy of binary without thinning; k > 0 runs at most k steps (fewer if the result is stable before). The result after k + 1 steps is a subset of the result after k steps. |
| inhibit | NULL, or a P26_U8 image of the shape of binary: its nonzero points that are object points are never removed. Its points outside the object are ignored (pink26 gives Pink inhibit AND binary: Pink's lskelMK2 would otherwise let them change the result). |
| out | Set to NULL on entry; receives a new P26_U8 image of the shape of binary, 1 on the result and 0 elsewhere (released with p26_image_free()). |
Complexity: O(N) time per step for N pixels (each step visits every pixel a bounded number of times), and at most about the thickness of the object in steps; memory: the framed copies of the object and of the inhibit image (1 byte per pixel each) and Pink's work images (1 or 2 bytes per pixel).
| p26_status p26_zhang_wang_thinning | ( | const p26_image * | binary, |
| int | max_steps, | ||
| p26_image ** | out ) |
Zhang-Wang parallel thinning (2D; Zhang and Wang 1988; Pink's lskelzhangwang).
In each step, every object pixel with 2 to 6 object 8-neighbours and exactly one 0-to-1 transition around it (crossing number 1) is removed at once, except where the object is 2 pixels thick (Zhang and Wang's correction of the Zhang-Suen thinning, which erased lines of that thickness); the steps repeat until no pixel changes. The result is thin, but the algorithm is NOT topologically sound: it may disconnect or erase small parts. The object is 8-connected (no connectivity parameter).
| binary | P26_U8 2D image; any nonzero value is an object point. |
| max_steps | As p26_parallel_skeleton(). |
| out | As p26_parallel_skeleton(). |
Complexity: as p26_parallel_skeleton().
| p26_status p26_guo_hall_thinning | ( | const p26_image * | binary, |
| int | variant, | ||
| int | max_steps, | ||
| p26_image ** | out ) |
Guo-Hall parallel thinning (2D; Guo and Hall 1992; Pink's lskelguohall).
In each step, every object pixel on the 4-border of the object with more than 2 object 8-neighbours and crossing number 1 is removed, except some configurations that depend on the variant:
| binary | P26_U8 2D image; any nonzero value is an object point. |
| variant | 1, 2 or 3 (Pink's skelpar commands 8, 9, 10). |
| max_steps | As p26_parallel_skeleton(). |
| out | As p26_parallel_skeleton(). |
Complexity: as p26_parallel_skeleton().