-
Notifications
You must be signed in to change notification settings - Fork 2
/
rgb_image.h
52 lines (39 loc) · 958 Bytes
/
rgb_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
/*
* rgb_image.h
*
* Created on: May 1, 2012
* Author: Hadi Esmaeilzadeh <[email protected]>
*/
#ifndef RGB_IMAGE_H_
#define RGB_IMAGE_H_
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
/// Struct storing rgb pixel value
typedef struct {
/// r value
float r;
/// g value
float g;
/// b value
float b;
} RgbPixel;
/// Struct storing rgb image
typedef struct {
/// width
int w;
/// height
int h;
/// array of arrays of rgb pixels
RgbPixel** pixels;
/// meta tag
char* meta;
} RgbImage;
void initRgbImage(RgbImage* image);
int loadRgbImage(const char* fileName, RgbImage* image);
RgbImage* allocRgbImage(int width, int height);
int saveRgbImage(RgbImage* image, const char* fileName, float grayscale);
void freeRgbImage(RgbImage* image);
void makeGrayscale(RgbImage* rgbImage);
void grayscale(RgbImage* image);
void checkIntegrity(RgbImage * image);
#endif /* RGB_IMAGE_H_ */