📄 texlib.c
字号:
/*************************************************************************** * texlib.c * written by: Stephanie Wojtkowski * * Description: The implementation of texlib.h: a library containing * functions that perform the Wei-Levoy texture synthesis method. ***************************************************************************/#include "texlib.h"/*************************************************************************** * GenerateTexture(input, r, c, output, h, w) * Inputs: input - original texture image * r - number of rows in input * c - number of columns in input * output - resulting texture image after Wei-Levoy * h - number of rows in output * w - number of columns in output * * Description: Given an image and the dimensions of the result, generates * a texture patch similar to the original of the given dimensions. ***************************************************************************/void GenerateTexture(Pixel *input, int r, int c, Pixel *output, int h, int w){ int i, j; int isize, osize; //input and output sizes Vector *outvec; isize = r*c; osize = h*w;#ifdef DEBUG printf("isize = %d, osize = %d, h=%d, w=%d\n", isize, osize, h, w);#endif outvec = (Vector *)malloc(osize*sizeof(Vector)); BuildTree(input, r, c, 20); Vectorize(output, h, w, outvec); //Perform the technique on the lower half of the image first to "seed" //the texture computations for the image for(i=osize/2; i<osize; i++) output[i] = FindMatch(outvec[i]); //For each position in the output image for(i=0; i<osize; i++){ //#ifdef DEBUG // printf("~~~~~~~~Find %dth match~~~~~~~~\n", i); //#endif output[i] = FindMatch(outvec[i]);#ifdef DEBUG if(i >= 3630 && i <= 3660) printf("Pixel %d: found match of (%d, %d, %d)\n", i, output[i].r, output[i].g, output[i].b);#endif }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -