pink26 0.1.1
Image processing and digital topology for teaching
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1/*
2Copyright Alain Lebret (2026)
3
4This software is an image processing library whose purpose is to be
5used primarily for research and teaching.
6
7This software is governed by the CeCILL license under French law and
8abiding by the rules of distribution of free software. You can use,
9modify and/ or redistribute the software under the terms of the CeCILL
10license as circulated by CEA, CNRS and INRIA at the following URL
11"http://www.cecill.info".
12
13As a counterpart to the access to the source code and rights to copy,
14modify and redistribute granted by the license, users are provided only
15with a limited warranty and the software's author, the holder of the
16economic rights, and the successive licensors have only limited
17liability.
18
19In this respect, the user's attention is drawn to the risks associated
20with loading, using, modifying and/or developing or reproducing the
21software by the user in light of its specific status of free software,
22that may mean that it is complicated to manipulate, and that also
23therefore means that it is reserved for developers and experienced
24professionals having in-depth computer knowledge. Users are therefore
25encouraged to load and test the software's suitability as regards their
26requirements in conditions enabling the security of their systems and/or
27data to be ensured and, more generally, to use and operate it in the
28same conditions as regards security.
29
30The fact that you are presently reading this means that you have had
31knowledge of the CeCILL license. You don't have to accept the License,
32but note that nothing other than this License grants you permission
33to use, propagate or modify any covered work.
34*/
35
49
50#ifndef PINK26_IMAGE_H
51#define PINK26_IMAGE_H
52
53#include <stddef.h>
54#include <pink26/status.h>
55
57enum { P26_MAX_NDIM = 3 };
58
60typedef enum {
61 P26_U8 = 1,
62 P26_I32 = 4,
63 P26_F32 = 5,
65} p26_dtype;
66
68typedef struct {
69 int ndim;
70 p26_index shape[P26_MAX_NDIM];
72 void *data;
74 double voxel[P26_MAX_NDIM];
75} p26_image;
76
84
102p26_status p26_checked_count(int ndim, const p26_index *shape, p26_dtype dtype,
103 p26_index *pixel_count, size_t *byte_count);
104
121p26_status p26_image_alloc(int ndim, const p26_index *shape, p26_dtype dtype, p26_image **out);
122
139p26_status p26_image_wrap(int ndim, const p26_index *shape, p26_dtype dtype, void *data,
140 p26_image **out);
141
148
165
172
179
186
187#endif /* PINK26_IMAGE_H */
p26_index p26_ds(const p26_image *img)
Depth size: number of pixels along z (Pink's depth); 1 for a 2D image.
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).
size_t p26_dtype_size(p26_dtype dtype)
Size in bytes of one pixel of the given type.
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_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_dtype
Pixel type.
Definition image.h:60
@ P26_U8
uint8_t (VFF_TYP_1_BYTE)
Definition image.h:61
@ P26_F64
double (VFF_TYP_DOUBLE)
Definition image.h:64
@ P26_F32
float (VFF_TYP_FLOAT)
Definition image.h:63
@ P26_I32
int32_t (VFF_TYP_4_BYTE)
Definition image.h:62
void p26_image_free(p26_image *img)
Releases an image descriptor, and its pixels if it owns them.
Status codes and error messages.
p26_status
Result of a pink26 function.
Definition status.h:75
int64_t p26_index
Pixel index or size in pixels (64-bit, so large 3D images fit).
Definition status.h:72
A 2D or 3D image.
Definition image.h:68
p26_index shape[P26_MAX_NDIM]
2D: (cs, rs, 1); 3D: (ds, cs, rs).
Definition image.h:70
p26_dtype dtype
Pixel type.
Definition image.h:71
int owns_data
1 if p26_image_free() releases data.
Definition image.h:73
int ndim
2 or 3.
Definition image.h:69
void * data
Pixels, C-contiguous, x fastest.
Definition image.h:72
double voxel[P26_MAX_NDIM]
Voxel size along x, y, z; 1.0 by default.
Definition image.h:74