|
pink26 0.1.1
Image processing and digital topology for teaching
|
The image descriptor shared by every pink26 operator. More...
Go to the source code of this file.
Data Structures | |
| struct | p26_image |
| A 2D or 3D image. More... | |
Enumerations | |
| enum | { P26_MAX_NDIM = 3 } |
| Largest number of axes of an image. | |
| enum | p26_dtype { P26_U8 = 1 , P26_I32 = 4 , P26_F32 = 5 , P26_F64 = 6 } |
| Pixel type. More... | |
Functions | |
| size_t | p26_dtype_size (p26_dtype dtype) |
| Size in bytes of one pixel of the given type. | |
| p26_status | p26_checked_count (int ndim, const p26_index *shape, p26_dtype dtype, p26_index *pixel_count, size_t *byte_count) |
| Validates an image geometry and computes its pixel and byte counts. | |
| p26_status | p26_image_alloc (int ndim, const p26_index *shape, p26_dtype dtype, p26_image **out) |
| Allocates an image whose pixels are all zero. | |
| p26_status | p26_image_wrap (int ndim, const p26_index *shape, p26_dtype dtype, void *data, p26_image **out) |
| Creates an image descriptor over pixels owned by the caller (no copy). | |
| void | p26_image_free (p26_image *img) |
| Releases an image descriptor, and its pixels if it owns them. | |
| p26_status | p26_image_validate (const p26_image *img) |
| Checks that a caller-supplied image descriptor can be used safely. | |
| p26_index | p26_rs (const p26_image *img) |
| Row size: number of pixels along x (Pink's rowsize). | |
| p26_index | p26_cs (const p26_image *img) |
| Column size: number of pixels along y (Pink's colsize). | |
| p26_index | p26_ds (const p26_image *img) |
| Depth size: number of pixels along z (Pink's depth); 1 for a 2D image. | |
The image descriptor shared by every pink26 operator.
A p26_image is a 2D or 3D array of pixels stored contiguously, x varying fastest, with the shape given in NumPy order (slowest axis first) so that the Python bindings can share the memory without copying.
Names inherited from Pink: rs (row size, the width along x), cs (column size, the height along y) and ds (depth size, along z) mirror Pink's rowsize(), colsize() and depth(). Pixel (x, y, z) has index i = z * rs * cs + y * rs + x, as in Pink.
| enum p26_dtype |
| size_t p26_dtype_size | ( | p26_dtype | dtype | ) |
Size in bytes of one pixel of the given type.
| dtype | Pixel type (any value). |
| p26_status p26_checked_count | ( | int | ndim, |
| const p26_index * | shape, | ||
| p26_dtype | dtype, | ||
| p26_index * | pixel_count, | ||
| size_t * | byte_count ) |
Validates an image geometry and computes its pixel and byte counts.
The products are checked: no intermediate result may exceed PTRDIFF_MAX.
| ndim | 2 or 3. |
| shape | ndim positive values, NumPy order (see p26_image). |
| dtype | Pixel type. |
| pixel_count | Receives the number of pixels; may be NULL. |
| byte_count | Receives the size of the pixel data in bytes; may be NULL. |
| p26_status p26_image_alloc | ( | int | ndim, |
| const p26_index * | shape, | ||
| p26_dtype | dtype, | ||
| p26_image ** | out ) |
Allocates an image whose pixels are all zero.
| ndim | 2 or 3. |
| shape | ndim positive values, NumPy order. For ndim == 2, image->shape[2] is set to 1. |
| dtype | Pixel type. |
| out | Set to NULL on entry; receives the new image (owns_data = 1, voxel sizes 1.0). The caller releases it with p26_image_free(). |
| p26_status p26_image_wrap | ( | int | ndim, |
| const p26_index * | shape, | ||
| p26_dtype | dtype, | ||
| void * | data, | ||
| p26_image ** | out ) |
Creates an image descriptor over pixels owned by the caller (no copy).
| ndim | 2 or 3. |
| shape | ndim positive values, NumPy order. |
| dtype | Pixel type. |
| data | Pixels, C-contiguous; must hold the whole image and outlive the descriptor. p26_image_free() does not release it. |
| out | Set to NULL on entry; receives the new descriptor (owns_data = 0, voxel sizes 1.0). |
| void p26_image_free | ( | p26_image * | img | ) |
Releases an image descriptor, and its pixels if it owns them.
| img | Image to release; NULL is accepted and does nothing. |
| p26_status p26_image_validate | ( | const p26_image * | img | ) |
Checks that a caller-supplied image descriptor can be used safely.
Images made by p26_image_alloc() or p26_image_wrap() are always valid. The fields of a p26_image are public, though, so a function that receives one from its caller calls this first, before it reads the shape (p26_rs() of an image with ndim 0 would read outside img->shape) or the pixels.
| img | Image to check. |
Row size: number of pixels along x (Pink's rowsize).
| img | A valid image (not NULL, ndim 2 or 3); not checked. |
Column size: number of pixels along y (Pink's colsize).
| img | A valid image (not NULL, ndim 2 or 3); not checked. |