|
pink26 0.1.1
Image processing and digital topology for teaching
|
Neighborhoods of digital topology on the square and cubic grids. More...
#include <pink26/image.h>Go to the source code of this file.
Data Structures | |
| struct | p26_neighborhood |
| The neighbors of a pixel for one connectivity and one image geometry. More... | |
Enumerations | |
| enum | { P26_NEIGHBORS_2D_MAX = 8 , P26_NEIGHBORS_3D_MAX = 26 } |
| Largest neighborhoods: 8 neighbors of a pixel, 26 neighbors of a voxel. | |
Functions | |
| p26_status | p26_neighborhood_init (const p26_image *img, int connectivity, p26_neighborhood *neighborhood) |
| Builds the neighborhood of the given connectivity for img's geometry. | |
| int | p26_neighbor (const p26_neighborhood *neighborhood, const p26_image *img, p26_index i, int k, p26_index *neighbor_index) |
| Finds neighbor k of pixel i, if it lies inside the image. | |
Neighborhoods of digital topology on the square and cubic grids.
In 2D a pixel has 4 neighbors sharing an edge with it, or 8 neighbors sharing an edge or a corner. In 3D a voxel has 6 neighbors sharing a face, 18 sharing a face or an edge, or 26 sharing a face, an edge or a corner. A p26_neighborhood lists the displacements (dx, dy, dz) of these neighbors, together with the matching index offsets for one image geometry. The order is Pink's in 2D; in 3D it is lexicographic (dz, dy, dx), which differs from Pink's voisin6/voisin18/voisin26: compare k-indexed tables with Pink only through (dx, dy, dz).
| p26_status p26_neighborhood_init | ( | const p26_image * | img, |
| int | connectivity, | ||
| p26_neighborhood * | neighborhood ) |
Builds the neighborhood of the given connectivity for img's geometry.
Neighbor order (k = 0 .. n-1), y pointing down as in Pink:
| img | Image whose geometry (rs, cs) gives the offsets. |
| connectivity | 4 or 8 for a 2D image; 6, 18 or 26 for a 3D image. |
| neighborhood | Receives the neighborhood. |
| int p26_neighbor | ( | const p26_neighborhood * | neighborhood, |
| const p26_image * | img, | ||
| p26_index | i, | ||
| int | k, | ||
| p26_index * | neighbor_index ) |
Finds neighbor k of pixel i, if it lies inside the image.
This is the safe, general accessor: it checks every bound. Inner loops of operators use neighborhood->offset directly after handling the border.
Only img->ndim is checked (this is called once per neighbor): img must be the image the neighborhood was built for, or one of the same geometry, otherwise the offsets do not match its rows and planes.
| neighborhood | Neighborhood built for img by p26_neighborhood_init(). |
| img | The image the neighborhood was built for. |
| i | Index of the pixel. |
| k | Rank of the neighbor, 0 .. neighborhood->n - 1. |
| neighbor_index | Receives the index of the neighbor when it exists. |