|
pink26 0.1.1
Image processing and digital topology for teaching
|
Homotopic operators on grayscale images: thinning, thickening, homotopic kernel and lambda-kernel ([BEC97], [CBB01]). More...
Go to the source code of this file.
Functions | |
| p26_status | p26_gray_homotopic_thinning (const p26_image *image, int connectivity, const p26_image *condition, int max_steps, p26_image **out) |
| Grayscale homotopic thinning ([BEC97], [CBB01]; Pink's lhthindelta, lhthindelta3d, command hthin). | |
| p26_status | p26_gray_homotopic_thickening (const p26_image *image, int connectivity, const p26_image *condition, int max_steps, p26_image **out) |
| Grayscale homotopic thickening ([BEC97], [CBB01]; Pink's lhthickdelta, lhthickdelta3d, command hthick). | |
| p26_status | p26_gray_homotopic_kernel (const p26_image *image, int connectivity, const p26_image *condition, p26_image **out) |
| Lower homotopic kernel ([BEC97], [CBB01] section 4.1; Pink's lhtkern, mctopo3d_lhtkern3d, command htkern). | |
| p26_status | p26_gray_lambda_kernel (const p26_image *image, int connectivity, int lambda, const p26_image *condition, p26_image **out) |
| Lambda-kernel, or filtered leveling kernel ([CBB01] section 5; Pink's llambdakern, command lambdaskel), corrected by pink26 (see "What pink26
changes" at the top of this file). | |
Homotopic operators on grayscale images: thinning, thickening, homotopic kernel and lambda-kernel ([BEC97], [CBB01]).
Cross-section topology. A grayscale image F is seen as a stack of binary images, its sections: for each level k, the section F_k is the set of the points p with F(p) >= k. An operator is homotopic when every section of the result has the topology of the same section of the input (same components and holes in 2D; also cavities and tunnels in 3D). On a 0/1 image there is one nonempty section, and these operators become binary thinning and thickening.
The points that may change, in plain words:
The operators:
Connectivity. In grayscale, the connectivity parameter is the connectivity of the MINIMA (of the dark regions), as in [CBB01] and Pink: the sections (the bright regions) use the complementary one. On a 0/1 image, connectivity 4 therefore thins like a binary 8-connected object on a 4-connected background, and connectivity 8 like a 4-connected object on an 8-connected background. Accepted values: 4 or 8 in 2D, 6 or 26 in 3D; 18 is refused (P26_E_UNSUPPORTED): Pink's 3D functions would silently treat it as 26.
Border. The points on the border of the image (its first and last rows and columns, and its first and last planes in 3D) are never modified: pink26 behaves like Pink and its commands htkern, hthin, hthick and lambdaskel. Hence:
Condition image (optional, P26_U8, shape of the image):
What pink26 changes in Pink's lambda-kernel (read this before comparing with Pink's command lambdaskel). [CBB01] appendix B (Algorithm lambda-Leveling, which has no condition image) lowers lambda-destructible points until stability. Pink's documentation of lambdaskel adds the condition G: "Repeat until stability: select a point p which is lambda-destructible ... such that F(p) > G(p)". Pink's llambdakern missed points of two kinds, which stayed lambda-destructible (even destructible) above the condition:
Size limit. Pink's thinning and thickening store a point index and a value in one 32-bit word, with 24 bits for the index: the image may have at most 2^24 = 16777216 points (4096 x 4096, or 256 x 256 x 256). pink26 applies this limit to the four operators (P26_E_UNSUPPORTED), before any call to Pink.
Pink functions used (lhtkern.c, lhtkern3d.c, llambdakern.c; Couprie, ESIEE):
pink26 function 2D 3D command p26_gray_homotopic_thinning lhthindelta lhthindelta3d hthin p26_gray_homotopic_thickening lhthickdelta lhthickdelta3d hthick p26_gray_homotopic_kernel lhtkern mctopo3d_lhtkern3d htkern p26_gray_lambda_kernel llambdakern (none) lambdaskel
References: [BEC97] G. Bertrand, J.-C. Everat, M. Couprie, "Image segmentation through operators based upon topology", Journal of Electronic Imaging 6(4), 1997, pp. 395-405 (no local copy; checked against reference 4 of [CBB01]). [CBB01] M. Couprie, F. N. Bezerra, G. Bertrand, "Topological operators for grayscale image processing", Journal of Electronic Imaging 10(4), 2001, pp. 1003-1015.
| p26_status p26_gray_homotopic_thinning | ( | const p26_image * | image, |
| int | connectivity, | ||
| const p26_image * | condition, | ||
| int | max_steps, | ||
| p26_image ** | out ) |
Grayscale homotopic thinning ([BEC97], [CBB01]; Pink's lhthindelta, lhthindelta3d, command hthin).
Lowers destructible points step by step (see the top of this file). The result is at most the input at every point and every section keeps its topology.
| image | P26_U8 image, 2D or 3D. |
| connectivity | Connectivity of the minima: 4 or 8 in 2D, 6 or 26 in 3D (the bright regions use the complementary one). |
| condition | NULL (0 everywhere), or a P26_U8 image of the shape of image: a lower bound (see the top of this file). |
| max_steps | Number of steps: any negative value runs until no point changes (the result is then a homotopic kernel); 0 returns a copy of image without calling Pink; k > 0 runs at most k steps. The result after k + 1 steps is at most the result after k steps at every point. |
| out | Set to NULL on entry; receives a new P26_U8 image of the shape of image (released with p26_image_free()). |
Complexity: O(N) time per step for N points, and about the size of the bright regions in steps; memory: the copies of image and condition (1 byte per point each), Pink's two point lists (4 bytes per point each) and its marks (1 byte per point).
| p26_status p26_gray_homotopic_thickening | ( | const p26_image * | image, |
| int | connectivity, | ||
| const p26_image * | condition, | ||
| int | max_steps, | ||
| p26_image ** | out ) |
Grayscale homotopic thickening ([BEC97], [CBB01]; Pink's lhthickdelta, lhthickdelta3d, command hthick).
The dual of p26_gray_homotopic_thinning(): raises constructible points step by step. The result is at least the input at every point and every section keeps its topology.
| image | As p26_gray_homotopic_thinning(). |
| connectivity | As p26_gray_homotopic_thinning(). |
| condition | NULL (255 everywhere), or a P26_U8 image of the shape of image: an upper bound (see the top of this file). |
| max_steps | As p26_gray_homotopic_thinning(); the result after k + 1 steps is at least the result after k steps. |
| out | As p26_gray_homotopic_thinning(). |
Complexity: as p26_gray_homotopic_thinning().
| p26_status p26_gray_homotopic_kernel | ( | const p26_image * | image, |
| int | connectivity, | ||
| const p26_image * | condition, | ||
| p26_image ** | out ) |
Lower homotopic kernel ([BEC97], [CBB01] section 4.1; Pink's lhtkern, mctopo3d_lhtkern3d, command htkern).
Lowers destructible points, lowest level first, until no point above its condition value is destructible (see the top of this file for the difference with thinning until stability). The result is at most the input, every section keeps its topology, and its minima are spread as much as possible: they are separated by thin crest lines.
| image | As p26_gray_homotopic_thinning(). |
| connectivity | As p26_gray_homotopic_thinning(). |
| condition | As p26_gray_homotopic_thinning() (a lower bound). |
| out | As p26_gray_homotopic_thinning(). |
Complexity: about O(N) time for N points (each point enters Pink's hierarchical queue on 256 levels a bounded number of times); memory: the copies of image and condition, Pink's queue (a few bytes per point) and its marks (1 byte per point).
| p26_status p26_gray_lambda_kernel | ( | const p26_image * | image, |
| int | connectivity, | ||
| int | lambda, | ||
| const p26_image * | condition, | ||
| p26_image ** | out ) |
Lambda-kernel, or filtered leveling kernel ([CBB01] section 5; Pink's llambdakern, command lambdaskel), corrected by pink26 (see "What pink26 changes" at the top of this file).
Lowers lambda-destructible points above their condition value, lowest level first, until none is left. The minima and the peaks of contrast at most lambda disappear; the result is at most the input, and no lambda-destructible point above its condition is left off the border. For lambda = 0 every section keeps its topology. The result may go below the condition (see the top of this file).
| image | P26_U8 2D image. |
| connectivity | Connectivity of the minima: 4 (Pink implements no other). |
| lambda | Contrast, in [0, 255]. |
| condition | NULL (0 everywhere), or a P26_U8 image of the shape of image: only points above it are selected (see the top of this file). |
| out | As p26_gray_homotopic_thinning(). |
Complexity: as p26_gray_homotopic_kernel(), plus a labelling of the minima (O(N), 4 bytes per point).