-
Notifications
You must be signed in to change notification settings - Fork 0
/
tc_image.h
executable file
·73 lines (52 loc) · 1.93 KB
/
tc_image.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* \file image.h
* \brief A simple lightweight image class
* \author David Ray Thompson
*
* Copyright 2012, by the California Institute of Technology. ALL RIGHTS
* RESERVED. United States Government Sponsorship acknowledged. Any
* commercial use must be negotiated with the Office of Technology
* Transfer at the California Institute of Technology.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#ifndef TC_IMAGE_H
#define TC_IMAGE_H
/* minimum single precision floating point is ~1.18e-38 */
#define MIN_PROB (2.678636961808078e-33f)
#define SMALL (10e-8f)
#define BIG (99999)
#define MAX_STRING (512)
// 255 and above is reserved, so this should never be that high
#define MAX_N_CLASSES (8)
#define ERR (0)
#define OK (1)
/* our basic bit depth */
typedef uint8_t pixel_t;
typedef struct tc_image_type
{
int rows;
int cols;
int chans;
pixel_t *data; /* row-major storage of pixels */
} tc_image;
pixel_t uchar_to_pixel(const unsigned char c);
pixel_t int_to_pixel(const int i);
unsigned char pixel_to_uchar(const pixel_t p);
void tc_write_log(const char *msg);
int tc_alloc_image(tc_image **img, const int rows,
const int cols, const int chans);
int tc_free_image(tc_image *img);
int tc_read_image(tc_image **img, const char *filename);
int tc_write_image(tc_image *img, const char *filename);
int tc_clone_image(tc_image **dst, tc_image *src);
int tc_crop_image(tc_image **dst, tc_image *src, const int top,
const int left, const int height, const int width);
int tc_copy_image(tc_image *dst, tc_image *src);
pixel_t tc_get(tc_image* img, const int row, const int col,
const int chan);
void tc_set(tc_image* img, const int row, const int col,
const int chan, const pixel_t val);
#endif