/* */ /* 幾何変換 */ /* */ #include #include #include #include "vision.h" /* 座標(x,y)における画素値 画像 image[][] 座標系:原点 = 格子点 [oi,oj] 格子点間隔 dx, dy */ double pixelvalue(double *image, int width, int height, int swidth, int sheight, int oi, int oj, double dx, double dy, double x, double y) { int i, j; double sx, sy, rx, ry; double c00, c10, c01, c11; double v; sx = floor(x/dx); sy = floor(y/dy); /* [i,j] = (x,y) の含まれるブロックの左下の格子点 */ i = sx + oi; j = sy + oj; if ( i<0 || i>width-1 || j<0 || j>height-1 ) { return 0; /* 画像の範囲外の場合 */ } rx = x - sx*dx; /* x/dx の余り */ ry = y - sy*dy; /* y/dy の余り */ c00 = (dx-rx)*(dy-ry)/dx/dy; c10 = (rx)*(dy-ry)/dx/dy; c01 = (dx-rx)* (ry)/dx/dy; c11 = (rx)* (ry)/dx/dy; v = c00 * ELEMENT(image,swidth,sheight,i, j) + c10 * ELEMENT(image,swidth,sheight,i+1, j) + c01 * ELEMENT(image,swidth,sheight,i, j+1) + c11 * ELEMENT(image,swidth,sheight,i+1,j+1); return v; } /* 画像の並進移動 画像 image[][] 座標系:原点 = 格子点 [oi,oj] 格子点間隔 dx, dy x,y 方向に distx,disty 並進移動 */ void imageTranslation(int width, int height, int swidth, int sheight, int oi, int oj, double dx, double dy, double *input, double distx, double disty, double *output) { int i, j; double xnew, ynew, x, y; for (i=0; i