#ifndef __INCLUDE_IPCOMMON_H__ #define __INCLUDE_IPCOMMON_H__ //----------------------------------------------------------------- // 定数定義 //----------------------------------------------------------------- extern UINT iHeight,iWidth,iLength; // 高さ,幅,1行幅 extern UINT iSize,biSize; // サイズ extern LPBYTE lpOrgBMP,lpBMP; // オリジナル画像, 表示画像 extern UINT iGHist[512]; // 濃淡用ヒストグラム //----------------------------------------------------------------- #ifndef M_PI #define M_PI 3.14159265358979323846 #endif //#define ROOT2 1.41421356 //#define BCC_WEIGHT (14.0-10.0*ROOT2) // 色定義 #define iWHITE 0xff #define iBLACK 0 #define iGRAY 100 #define iMAX_GRAY 256 #define iRED 2 #define iGREEN 1 #define iBLUE 0 //----------------------------------------------------------------- // マクロ宣言 //----------------------------------------------------------------- // calc image pointer index #define XY2PI(x,y,w) ((x)+(y)*w) // check point #define ip_safe(x,y,w,h) (x>=0 && x=0 && y=0)?((int)(x+0.5)):((int)(x-0.5))) // degree to radian #define deg2rad(x) ((double)x*M_PI/180.) // radian to degree #define rad2deg(x) ((double)x*180./M_PI) //----------------------------------------------------------------- enum COLOR_DEF { COLOR_R = 0, COLOR_G = 1, COLOR_B = 2, COLOR_Y = 3, COLOR_U = 4, COLOR_V = 5, COLOR_RHO = 6, COLOR_THETA = 7, COLOR_RGB = 8 }; // 補間形式 enum INTERPOLATION { INTP_NN = 0, INTP_LN = 1, INTP_BCC = 2, }; // RGB色 typedef struct COLOR_PIXEL { BYTE r,g,b; } CPIXEL; // 近接画素へのオフセット static POINT offset8[8] = { {-1,-1},{ 0,-1},{ 1,-1}, {-1, 0},{ 1, 0}, {-1, 1},{ 0, 1},{ 1, 1} }; // 近接画素へのオフセット static POINT offset9[9] = { {-1,-1},{ 0,-1},{ 1,-1}, {-1, 0},{ 0, 0},{ 1, 0}, {-1, 1},{ 0, 1},{ 1, 1} }; //----------------------------------------------------------------- // 諸関数 //----------------------------------------------------------------- int lcm(int a,int b); void init_random(); int random_int(int n); void swapv(int c1,int c2); void swap_point(POINT p1,POINT p2); int colcmp(LPBYTE inb,CPIXEL c2); void setcol(LPBYTE inb,CPIXEL c); double calc_distance(POINT p1,POINT p2); double calc_distance(int x1,int y1,int x2,int y2); double calc_mean(int n,double* a); double calc_sd(int n,double* a); void standalize_data(int n,double* a); void normalize_data(int n,double* a); //----------------------------------------------------------------- // 表色系の変換 //----------------------------------------------------------------- BYTE rgb2gray(BYTE r,BYTE g,BYTE b); void rgb2yuv(BYTE r,BYTE g,BYTE b,BYTE &y,BYTE &u,BYTE &v); BYTE rgb2y(BYTE r,BYTE g,BYTE b); BYTE rgb2u(BYTE r,BYTE g,BYTE b); BYTE rgb2v(BYTE r,BYTE g,BYTE b); void rgb2rth(BYTE r,BYTE g,BYTE b,BYTE &rho,BYTE &th); BYTE rgb2rho(BYTE r,BYTE g,BYTE b); BYTE rgb2theta(BYTE r,BYTE g,BYTE b); //----------------------------------------------------------------- // 描画関数 //----------------------------------------------------------------- void draw_circle(LPBYTE oBuf,POINT cp,int radius); void draw_line(LPBYTE oBuf,POINT p1,POINT p2,int col=iWHITE); void draw_line(LPBYTE oBuf,int x1,int y1,int x2,int y2,int col=iWHITE); int croslnxc(int x1,int y1,int x2,int y2,int xc,int *yc); int croslnyc(int x1,int y1,int x2,int y2,int yc,int *xc); int scrossln(int* x1,int* y1,int* x2,int* y2); void mark_template_area(LPBYTE inBuf,POINT tp,int txsize,int tysize); //----------------------------------------------------------------- // 画像処理関数 //----------------------------------------------------------------- void make_histogram(LPBYTE inBuf); void GrayToColor(LPBYTE iGray,LPBYTE iColor); void toGray(LPBYTE inBuf); void toCGray(LPBYTE inBuf,int csel); void toGray(); LPBYTE GetGray(); LPBYTE GetColor(int csel); void affine_transform(LPBYTE inBuf,int intp_opt, double zx,double zy, double deg,double px,double py); void c_affine_transform(LPBYTE inBuf,int intp_opt, double zx,double zy, double deg,double px,double py); BYTE image_interpolation(LPBYTE ib,int intp_opt, double x,double y,int xc,int yc); CPIXEL c_image_interpolation(LPBYTE icb,int intp_opt, double x,double y,int xc,int yc); void nn_scale(LPBYTE image_in,double zx,double zy); void linear_scale(LPBYTE inBuf,double zx,double zy); void bcc_scale(LPBYTE inBuf,double zx,double zy); void sqm_scale(LPBYTE inBuf,double zx,double zy); void c_sqm_scale(LPBYTE inBuf,double zx,double zy); void IPfunc_OR(LPBYTE iDst,LPBYTE iAdd); void IPfunc_median(LPBYTE inBuf); BYTE median(BYTE c[9]); void toDither(LPBYTE inBuf); void linear_transform(LPBYTE inBuf); void change_graylevel(LPBYTE inBuf,int iLevel); void spacial_filtering(LPBYTE inBuf,int iFlt[9],double iMag); void make_error_difusion_image(LPBYTE inBuf); void make_histogram_image(LPBYTE inBuf); void draw_3D_graph(LPBYTE inBuf,int plot_step=5,double plot_ratio=1.0); //----------------------------------------------------------------- #endif // __INCLUDE_IPCOMMON_H__