-
Notifications
You must be signed in to change notification settings - Fork 2
/
alg1.h
106 lines (79 loc) · 3.65 KB
/
alg1.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* ############################################################################
Name : alg1.h
Company : S. Vagionitis
Project : Finding Clones
Programmer : S. Vagionitis
Revisor : S. Vagionitis
Description : Header file for alg_lvl1.c.
Programmer Date Action
============== ============== =================================================
S. Vagionitis 10/06/2010 Creation
############################################################################ */
#ifndef __ALG1_H__
#define __ALG1_H__
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define PI 3.1415926535897932384626433832795
#define RAD(x) ((x)*PI/180.0)
#define MIN(a,b) ((a)<=(b)?(a):(b))
#define MAX(a,b) ((a)>=(b)?(a):(b))
#define MIN3(a,b,c) ((a)<=(b) ? (a)<=(c)?(a):(c) : (b)<=(c)?(b):(c) )
#define MAX3(a,b,c) ((a)>=(b) ? (a)>=(c)?(a):(c) : (b)>=(c)?(b):(c) )
#define GREYSCALE1(r, g, b) ((unsigned char)(0.2126 * (double)(r)) + \
(unsigned char)(0.7152 * (double)(g)) + \
(unsigned char)(0.0722 * (double)(b)))
#define GREYSCALE2(r, g, b) ((unsigned char)(0.2989 * (double)(r)) + \
(unsigned char)(0.5870 * (double)(g)) + \
(unsigned char)(0.1140 * (double)(b)))
/*
* M x M regions that image will be divided.
* We could use also 24, 18 and 12 as stated in the paper.
*/
#define M 32
/*
* Number of pixels to shift the M x M window.
*/
#define SHIFT (M/2)
#define HEIGHT_DIV_SHIFT(h, s) (((h) / (s)))
#define HEIGHT_MOD_SHIFT(h, s) ((h) % (s))
#define WIDTH_DIV_SHIFT(w, s) (((w) / (s)))
#define WIDTH_MOD_SHIFT(w, s) ((w) % (s))
/*
* 8-bit colors
*/
#define COLORS 256
/*
* For Step 5: Repeat steps 2 through 4 until the difference
* in T in successive iterations is smaller than a predefined
* parameter DIFF_T.
*/
#define DIFF_T 0.01
#pragma pack(1)
/*Structure for histogram*/
typedef struct histogram_t{
unsigned int num_pixels;
float freq;
}histogram;
int Calculate_Block_Size(unsigned int, unsigned int, int, int, unsigned int *, unsigned int *);
int create_sub_images(unsigned char *, int, int, unsigned int *, unsigned int *);
int free_mem_subimages(int, int, unsigned int, unsigned int);
int export_ppm_subimages(unsigned char, int, int, unsigned int, unsigned int);
int calculate_histogram(unsigned char, int, int, unsigned int, unsigned int);
int free_mem_histogram(unsigned int, unsigned int);
int calculate_threshold(int, int, unsigned int, unsigned int);
int calculate_min_max_hist_threshold(unsigned int, unsigned int, unsigned char *, unsigned char *);
int basic_global_thresholding_algorithm(unsigned int, unsigned int, float, unsigned char *);
int calculate_threshold_with_interpolation(unsigned char, int, int, unsigned int, unsigned int);
int bilinear_interpolation_with_weights_propotional_to_square_of_distance(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned char*);
int bilinear_interpolation_with_weights_propotional_to_distance(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned char*);
int linear_interpolation_in_2d_data(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned char*);
int reconstruct_image_from_subimages(unsigned char, int, int, unsigned int, unsigned int);
int final_stage(int, int, unsigned int, unsigned int);
extern unsigned char *****subimage_data;
extern histogram ***hist_data;
extern unsigned char **Ts;
#endif