01: #ifndef __INCLUDE_IPCOMMON_H__
02: #define __INCLUDE_IPCOMMON_H__
03:
04:
05: #ifndef M_PI
06: #define M_PI 3.14159265358979323846
07: #endif
08:
09: #define rint(x) ((x>=0)?((int)(x+0.5)):((int)(x-0.5)))
10:
11: #define deg2rad(x) ((double)x*M_PI/180.)
12:
13:
14: enum IMG_COLOR {
15: iWHITE = 255, iBLACK = 0, iGRAY = 128, iMAX_GRAY = 256,
16: };
17: enum RGB_COLOR {
18: iRED = 2, iGREEN = 1, iBLUE = 0,
19: };
20:
21: typedef struct COLOR_PIXEL {
22: BYTE r,g,b;
23: } CPIXEL;
24:
25: static POINT offset8[8] = {
26: {-1,-1},{ 0,-1},{ 1,-1},
27: {-1, 0},{ 1, 0},
28: {-1, 1},{ 0, 1},{ 1, 1}
29: };
30:
31: static POINT offset9[9] = {
32: {-1,-1},{ 0,-1},{ 1,-1},
33: {-1, 0},{ 0, 0},{ 1, 0},
34: {-1, 1},{ 0, 1},{ 1, 1}
35: };
36:
37: extern UINT iHeight,iWidth,iLength,iSize;
38: extern LPBYTE lpOrgBMP,lpBMP;
39: extern UINT iGHist[512];
40:
41:
42:
43: void init_random();
44: int random_int(int n);
45: void swap_col(BYTE c1,BYTE c2);
46: BYTE rgb2gray(BYTE r,BYTE g,BYTE b);
47: void swap_point(POINT p1,POINT p2);
48: int colcmp(LPBYTE inb,CPIXEL c2);
49: void setcol(LPBYTE inb,CPIXEL c);
50: double calc_distance(POINT p1,POINT p2);
51: double calc_distance(int x1,int y1,int x2,int y2);
52:
53:
54:
55: void draw_circle(LPBYTE oBuf,POINT cp,int radius);
56: void draw_line(LPBYTE oBuf,POINT p1,POINT p2);
57: void draw_line(LPBYTE oBuf,int x1,int y1,int x2,int y2);
58: int croslnxc(int x1,int y1,int x2,int y2,int xc,int *yc);
59: int croslnyc(int x1,int y1,int x2,int y2,int yc,int *xc);
60: int scrossln(int* x1,int* y1,int* x2,int* y2);
61:
62:
63:
64: void GrayToColor(LPBYTE iGray,LPBYTE iColor);
65: void toGray();
66: LPBYTE GetGray();
67: LPBYTE GetColor(int csel);
68: void IPfunc_OR(LPBYTE iDst,LPBYTE iAdd);
69: void IPfunc_median(LPBYTE inBuf);
70: BYTE median(BYTE c[9]);
71: void toDither(LPBYTE inBuf);
72: void linear_transform(LPBYTE inBuf);
73: void change_graylevel(LPBYTE inBuf,int iLevel);
74: void spacial_filtering(LPBYTE inBuf,int iFlt[9],double iMag);
75:
76:
77: #endif