OCR Project
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1
13
14#ifndef IMAGE_H
15#define IMAGE_H
16
17#include <stddef.h>
18#include <stdint.h>
19
20/* -------------------------------------------------------------------------
21 * Opaque pixel buffer
22 * ---------------------------------------------------------------------- */
23
27typedef struct {
28 uint8_t *pixels;
29 int width;
30 int height;
31} Image;
32
33/* -------------------------------------------------------------------------
34 * Preprocessing parameters
35 * ---------------------------------------------------------------------- */
36
40typedef struct {
42 int invert;
44
45/* -------------------------------------------------------------------------
46 * Public API
47 * ---------------------------------------------------------------------- */
48
56Image *image_load_png(const char *path);
57
63void image_free(Image *img);
64
75void image_to_grayscale(Image *img);
76
86void image_binarize(Image *img);
87
99Image *image_resize(const Image *img, int w, int h);
100
112Image *image_rotate(const Image *img, float angle_deg);
113
123void image_to_float(const Image *img, float *out);
124
135int image_load_normalised(const char *path, const PreprocessParams *p,
136 float *out, int out_h, int out_w);
137
145int image_save_png(const Image *img, const char *path);
146
147#endif /* IMAGE_H */
void image_to_grayscale(Image *img)
Convert an Image to grayscale in-place.
Definition image.c:189
Image * image_load_png(const char *path)
Load a PNG file into an Image.
Definition image.c:52
int image_load_normalised(const char *path, const PreprocessParams *p, float *out, int out_h, int out_w)
Full pipeline: load PNG → preprocess → resize → float array.
Definition image.c:340
int image_save_png(const Image *img, const char *path)
Save an Image as a PNG file.
Definition image.c:143
Image * image_rotate(const Image *img, float angle_deg)
Rotate an Image by angle_deg degrees clockwise.
Definition image.c:257
void image_free(Image *img)
Free an Image allocated by image_load_png().
Definition image.c:40
void image_binarize(Image *img)
Binarise a grayscale Image in-place using a global threshold.
Definition image.c:204
Image * image_resize(const Image *img, int w, int h)
Resize an Image to the given dimensions (nearest-neighbour).
Definition image.c:227
void image_to_float(const Image *img, float *out)
Convert an Image to a flat normalised float array.
Definition image.c:328
Heap-allocated RGBA pixel buffer (row-major, 4 bytes per pixel).
Definition image.h:27
int height
Definition image.h:30
uint8_t * pixels
Definition image.h:28
int width
Definition image.h:29
Parameters for the full preprocessing pipeline.
Definition image.h:40
float rotation_deg
Definition image.h:41
int invert
Definition image.h:42