-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.h
92 lines (71 loc) · 2.6 KB
/
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef IMAGE_H
#define IMAGE_H
#include <opencv/cv.h>
#define NEWA(type,n) (type*)malloc(sizeof(type)*(n))
#define NEW(type) NEWA(type,1)
typedef struct {
int width, height;
unsigned char* r;
unsigned char* g;
unsigned char* b;
} image_rgb;
typedef struct {
int width, height;
unsigned char* data;
} image_gray;
typedef struct {
int width, height;
float* h; // [0,1]
float* s; // [0,1]
float* l; // [0,1]
} image_hsl;
typedef struct {
int width, height;
float* h; // [0,1]
float* s; // [0,1]
float* v; // [0,1]
} image_hsv;
typedef struct {
int nr;
int nc;
int*seglable;
int lablenum;
} ncut_seg;
/* ************************************************** */
/* a group of functions which create or delete images */
image_hsl* image_hsl_new(int width, int height);
image_hsv* image_hsv_new(int width, int height);
image_gray* image_gray_new(int width, int height);
image_rgb* image_rgb_new(int width, int height);
void image_hsl_delete(image_hsl* image);
void image_hsv_delete(image_hsv* image);
void image_gray_delete(image_gray* image);
void image_rgb_delete(image_rgb* image);
/* ************************************************** */
// read a RGB image from a common compressed image format(such as 'JPG', 'BMP' etc), using OpenCV
image_rgb* load_image(const char *fname, int iscolor); // tested JPG & BMP format, and it should also works for other common format
// load an image from an OpenCV format image
image_rgb* load_cv_image(IplImage *image);
// convert RGB color space to HSL color space
image_hsl* rgb2hsl(image_rgb *rgb); // tested
// convert RGB color space to HSV color space
image_hsv* rgb2hsv(image_rgb *rgb); // tested
// convert RGB color space to gray level
image_gray* rgb2gray(image_rgb *rgb); // tested
// get gray level histogram
int* get_gray_histogram(image_gray* gray); // tested
// get RGB histogram
int* get_rgb_histogram(image_rgb* rgb); // tested
// get HSV histogram
int* get_hsv_histogram(image_hsv* hsv); ///////////////////////
// get hue histogram
int* get_hue_histogram(image_hsv* hsv); // tested
float *get_saliency_map(image_rgb* rgb);
//normalized cut related
int count_segarea(int*seglable,int size,int lable);//tested
int* segment_hue_histogram(int*seglable,image_hsv* imagehsv,int nr,int nc,int lablenum);//tested
int* maxarea_segment(int*seglable,int size,int lablenum);//tested
//返回的ncut_seg中的seglable成员指向动态分配的内存,注意最后释放掉
ncut_seg ncut_main_seg_from_file(char* filename,int nr,int nc);
ncut_seg ncut_main_seg_from_memory(int* seglable,int nr,int nc);
#endif /* IMAGE_H */