|
pink26 0.1.1
Image processing and digital topology for teaching
|
Distance maps of binary images. More...
Go to the source code of this file.
Enumerations | |
| enum | p26_distance_kind { P26_DISTANCE_SQUARED_EUCLIDEAN = 0 , P26_DISTANCE_CHAMFER = 1 , P26_DISTANCE_D4 = 4 , P26_DISTANCE_D8 = 8 , P26_DISTANCE_D6 = 6 , P26_DISTANCE_D18 = 18 , P26_DISTANCE_D26 = 26 } |
| Kind of distance. More... | |
Functions | |
| p26_status | p26_distance_map (const p26_image *binary, p26_distance_kind kind, p26_image **out) |
| Computes, for every object point, the distance to the nearest background point; the outside of the image counts as background. | |
Distance maps of binary images.
The distance of an object point to the background is the length of the shortest path, or the straight-line distance, to the nearest background point. Every image is surrounded by an infinite background, so the points of the image frame are at distance 1 from the outside (as for p26_simple_points()).
The distances are those of Pink's ldist.c (Couprie, ESIEE): see p26_distance_kind for the exact definition of each one.
| enum p26_distance_kind |
Kind of distance.
The value of the D4 ... D26 constants is the number of the neighbors used (Pink's connectivity argument); SQUARED_EUCLIDEAN and CHAMFER are 0 and 1.
| p26_status p26_distance_map | ( | const p26_image * | binary, |
| p26_distance_kind | kind, | ||
| p26_image ** | out ) |
Computes, for every object point, the distance to the nearest background point; the outside of the image counts as background.
Pink computes the D4 ... D26 and chamfer distances on an image whose object and background are exchanged (its "external distance"); the squared Euclidean distance is computed on the image as it is. In every case pink26 works on a copy of the image with a frame of background and gives back the interior.
Range: the squared Euclidean distance is computed in 32 bits; it is exact when the largest possible value, (rs + 2)^2 + (cs + 2)^2 [+ (ds + 2)^2 in 3D], is at most INT32_MAX: about 32000 pixels along each side in 2D, and 26000 in a cubic volume. Beyond that the call may return P26_E_OVERFLOW if a value is negative as int32, but a wrapped value that stays positive is not detected: do not rely on larger images. The other distances are at most 7 times the image diameter and never wrap.
Complexity: O(N) time and memory for the squared Euclidean distance and the D4 ... D26 distances (N is the number of pixels); the chamfer distance repeats two passes over the image until nothing changes (a few passes, at most about the image diameter).
| binary | P26_U8 image; any nonzero value is an object point. |
| kind | Kind of distance, see p26_distance_kind. |
| out | Set to NULL on entry; receives a new P26_I32 image of the shape of binary (released with p26_image_free()): 0 on the background, the distance (at least 1) on the object. |