[PR]生年月日で2010年占い鑑定:初回無料!貴女の運命運勢を占う
001: #ifndef __INCLUDE_IPCOMMON_H__
002: #define __INCLUDE_IPCOMMON_H__
003:
004: #include <stdlib.h>
005: #include <time.h>
006: #include <math.h>
007: #include <windows.h>
008: #include "wingui.h"
009:
010:
011:
012: extern int iHeight,iWidth,iLength;
013: extern int iSize,biSize;
014: extern int iGHist[512],iCHist[3][512];
015: extern LPBYTE lpOrgBMP,lpBMP;
016:
017: #ifndef M_PI
018: #define M_PI 3.14159265358979323846
019: #endif
020:
021: #define iWHITE 0xff
022: #define iBLACK 0
023: #define iGRAY 100
024: #define iMAX_GRAY 256
025: #define iRED 2
026: #define iGREEN 1
027: #define iBLUE 0
028: #define CBIT 8
029:
030:
031:
032:
033: #define XY1D(x,y,w) ((x)+(y)*w)
034:
035: #define ip_safe(x,y,w,h) ((x)>=0 && (x)<(w) && (y)>=0 && (y)<(h))
036:
037: #define rint(x) ((x>=0)?((int)(x+0.5)):((int)(x-0.5)))
038:
039: #define deg2rad(x) ((double)(x)*M_PI/180.)
040:
041: #define rad2deg(x) ((double)(x)*180./M_PI)
042:
043: #define calc_pw(x,y) (sqrt((x)*(x)+(y)*(y)))
044: #define calc_sq(x,y) ((x)*(x)+(y)*(y))
045:
046: enum COLOR_DEF {
047: COLOR_R = 0, COLOR_G = 1, COLOR_B = 2,
048: COLOR_GRAY = 3,
049: COLOR_Y = 4, COLOR_U = 5, COLOR_V = 6,
050: COLOR_RHO = 7, COLOR_THETA = 8,
051: COLOR_RGB = 9,
052: };
053:
054: enum INTERPOLATION {
055: INTP_NN = 0, INTP_LN = 1, INTP_BCC = 2,
056: };
057:
058: typedef struct COLOR_PIXEL { BYTE r,g,b; } CPIXEL;
059:
060: static POINT offset8[8] = {
061: {-1,-1},{ 0,-1},{ 1,-1},
062: {-1, 0},{ 1, 0},
063: {-1, 1},{ 0, 1},{ 1, 1}
064: };
065:
066: static POINT offset9[9] = {
067: {-1,-1},{ 0,-1},{ 1,-1},
068: {-1, 0},{ 0, 0},{ 1, 0},
069: {-1, 1},{ 0, 1},{ 1, 1}
070: };
071:
072:
073:
074: int lcm(int a,int b);
075: void init_random();
076: int random_int(int n);
077: void swapv(int c1,int c2);
078: void swap_point(POINT p1,POINT p2);
079: int colcmp(LPBYTE inb,CPIXEL c2);
080: void setcol(LPBYTE inb,CPIXEL c);
081: double calc_distance(POINT p1,POINT p2);
082: double calc_distance(int x1,int y1,int x2,int y2);
083: double calc_mean(int n,double* a);
084: double calc_sd(int n,double* a);
085: void standalize_data(int n,double* a);
086: void normalize_data(int n,double* a);
087:
088:
089:
090: BYTE rgb2gray(BYTE r,BYTE g,BYTE b);
091: void rgb2yuv(BYTE r,BYTE g,BYTE b,BYTE &y,BYTE &u,BYTE &v);
092: BYTE rgb2y(BYTE r,BYTE g,BYTE b);
093: BYTE rgb2u(BYTE r,BYTE g,BYTE b);
094: BYTE rgb2v(BYTE r,BYTE g,BYTE b);
095: void rgb2rth(BYTE r,BYTE g,BYTE b,BYTE &rho,BYTE &th);
096: BYTE rgb2rho(BYTE r,BYTE g,BYTE b);
097: BYTE rgb2theta(BYTE r,BYTE g,BYTE b);
098:
099:
100:
101: void draw_circle(LPBYTE oBuf,POINT cp,int radius);
102: void draw_line(LPBYTE oBuf,POINT p1,POINT p2,int col=iWHITE);
103: void draw_line(LPBYTE oBuf,int x1,int y1,int x2,int y2,int col=iWHITE);
104: void c_draw_line(LPBYTE oBuf,int x1,int y1,int x2,int y2);
105: void c_draw_line(LPBYTE oBuf,int x1,int y1,int x2,int y2,CPIXEL col);
106: int croslnxc(int x1,int y1,int x2,int y2,int xc,int *yc);
107: int croslnyc(int x1,int y1,int x2,int y2,int yc,int *xc);
108: int scrossln(int* x1,int* y1,int* x2,int* y2);
109: void mark_template_area(LPBYTE inBuf,POINT tp,int txsize,int tysize);
110:
111:
112:
113: void make_histogram(LPBYTE inBuf);
114: void c_make_histogram(LPBYTE inBuf);
115: void GrayToColor(LPBYTE iGray,LPBYTE iColor);
116: void RGBToColor(LPBYTE icol,LPBYTE iR,LPBYTE iG,LPBYTE iB);
117: void toGray(LPBYTE inBuf,int csel=COLOR_GRAY);
118: void toGray();
119: LPBYTE GetGray(int csel=COLOR_GRAY);
120: LPBYTE GetColor();
121:
122:
123:
124: void affine_transform(LPBYTE inBuf,int intp_opt,
125: double zx,double zy,
126: double deg,double px,double py);
127: void c_affine_transform(LPBYTE inBuf,int intp_opt,
128: double zx,double zy,
129: double deg,double px,double py);
130: BYTE image_interpolation(LPBYTE ib,int intp_opt,
131: double x,double y,int xc,int yc);
132: CPIXEL c_image_interpolation(LPBYTE icb,int intp_opt,
133: double x,double y,int xc,int yc);
134: void nn_scale(LPBYTE image_in,double zx,double zy);
135: void linear_scale(LPBYTE inBuf,double zx,double zy);
136: void bcc_scale(LPBYTE inBuf,double zx,double zy);
137: void sqm_scale(LPBYTE inBuf,double zx,double zy);
138: void c_sqm_scale(LPBYTE inBuf,double zx,double zy);
139: LPBYTE scale_large(LPBYTE inb,double zx,double zy);
140:
141:
142:
143: void IPfunc_OR(LPBYTE iDst,LPBYTE iAdd);
144: void IPfunc_median(LPBYTE inBuf);
145: BYTE median(BYTE c[9]);
146: void toDither(LPBYTE inBuf);
147: void linear_transform(LPBYTE inBuf);
148: void reduce_color(LPBYTE inBuf,int iLevel);
149: void c_reduce_color(LPBYTE inBuf,int iLevel);
150: void quantize(LPBYTE inBuf,int bit);
151: void c_quantize(LPBYTE inBuf,int bit);
152: void spacial_filtering(LPBYTE inBuf,int iFlt[9],double iMag);
153: void make_error_difusion_image(LPBYTE inBuf);
154: void make_histogram_image(LPBYTE inBuf);
155: void draw_3D_graph(LPBYTE inBuf,int plot_step=5,double plot_ratio=1.0);
156:
157:
158: #endif