• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MAT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MAT函数的典型用法代码示例。如果您正苦于以下问题:C++ MAT函数的具体用法?C++ MAT怎么用?C++ MAT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MAT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: cleanOut

static bool cleanOut(const char* dir) {
	printf("cleanOut(%s)\n", dir);
	MAHandle list = maFileListStart(dir, "*");
	MAT(list);
	char buf[2048];
	int dirLen = strlen(dir);
	strcpy(buf, dir);
	int freeBufSpace = sizeof(buf) - dirLen;
	while(1) {
		int res;
		MAHandle fh;
		char* fileName = buf + dirLen;
		res = maFileListNext(list, fileName, freeBufSpace);
		MAT_CUSTOM(res, (_res < 0 || _res >= freeBufSpace));
		if(res == 0)
			return true;
		if(fileName[res-1] == '/') {
			if(!cleanOut(buf))
				return false;
		}
		MAT(fh = maFileOpen(buf, MA_ACCESS_READ_WRITE));
		res = maFileDelete(fh);
		MAASSERT(maFileClose(fh) == 0);
		MAT(res);
	}
	MAASSERT(maFileListClose(list) == 0);
	return true;
}
开发者ID:comforx,项目名称:MoSync,代码行数:28,代码来源:setup_filesystem.c


示例2: test

int test(lua_State *L) {
	float data[12] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.};
	float out_data[12];
	
	VecN<float, 6> *v_in = (VecN<float, 6> *)data;
	VecN<float, 6> *v_out = (VecN<float, 6> *)out_data;
	for(int i=0; i < 2; i++) {
		int oo[] = {1, 0};
		int ii[] = {0, 1};
		MAT(v_out) = MAT(v_in)+MAT(v_in);
		swizzle(MAT(v_out), MAT(v_in), 2, oo, ii);
		v_in++;
		v_out++;
	}
	
	for(int j=0; j < 12; j++) {
		printf("j: %f\n", out_data[j]);
	}
	
	/*
	Vec3<char> v1c(64, 123, 5);
	v1c = v1c*0.5;
	printf("t: %d %d %d\n", v1c.x, v1c.y, v1c.z);
	*/
	return 0;
}
开发者ID:LuaAV,项目名称:LuaAV,代码行数:26,代码来源:test.code.cpp


示例3: _equalf

static int _equalf(CMATRIX *a, double f)
{
	bool result;
	
	if (COMPLEX(a))
	{
		if (f == 0.0)
			return gsl_matrix_complex_isnull(CMAT(a));
		
		gsl_matrix_complex *m = gsl_matrix_complex_alloc(WIDTH(a), HEIGHT(a));
		gsl_matrix_complex_set_identity(m);
		gsl_matrix_complex_scale(m, gsl_complex_rect(f, 0));
		result = gsl_matrix_complex_equal(CMAT(a), m);
		gsl_matrix_complex_free(m);
	}
	else
	{
		if (f == 0.0)
			return gsl_matrix_isnull(MAT(a));
		
		gsl_matrix *m = gsl_matrix_alloc(WIDTH(a), HEIGHT(a));
		gsl_matrix_set_identity(m);
		gsl_matrix_scale(m, f);
		result = gsl_matrix_equal(MAT(a), m);
		gsl_matrix_free(m);
	}
	
	return result;
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:29,代码来源:c_matrix.c


示例4: getPixelValue

float getPixelValue(struct matrix* image,uint32 imgPosX,uint32 imgPosY,
		uint32 filterPosX,uint32 filterPosY,uint8 mode)
{
	float pixelValue = 0.0;
	// add the image and filter position
	sint32 imgCurrentPosX = imgPosX+filterPosX;
	sint32 imgCurrentPosY = imgPosY+filterPosY;

	// check whether the resulting added position lies outside the image boundary
	if((imgCurrentPosX < 0) ||
		(imgCurrentPosX > (image->numberOfRows-1)) ||
		(imgCurrentPosY < 0) ||
		(imgCurrentPosY > (image->numberOfColumns-1)))
	{
			// values outside the bounds of the image are the nearest array borders
			if(mode == MODE_REPLICATE)
			{
				imgCurrentPosX = ((imgCurrentPosX < 0) ? 0 : (imgCurrentPosX > image-> numberOfRows-1) ? (image-> numberOfRows-1) : imgCurrentPosX);
				imgCurrentPosY = ((imgCurrentPosY < 0) ? 0 : (imgCurrentPosY > image-> numberOfColumns-1) ? (image-> numberOfColumns-1) : imgCurrentPosY);

				pixelValue = MAT(image,imgCurrentPosX,imgCurrentPosY);
			}
			// values outside the bounds of the image are mirror reflecting the array across the border
			else if(mode == MODE_SYMMETRIC)
			{
				if(imgCurrentPosX < 0 || imgCurrentPosX > image->numberOfRows-1)
				{
					imgCurrentPosX = (image->numberOfRows -1) - (mod(imgCurrentPosX,image->numberOfRows));
				}
				if(imgCurrentPosY < 0 || imgCurrentPosY > image->numberOfColumns-1)
				{
					imgCurrentPosY = (image->numberOfColumns -1) - (mod(imgCurrentPosY,image->numberOfColumns));
				}

				pixelValue = MAT(image,imgCurrentPosX,imgCurrentPosY);
			}
			// values outside the bounds of the image are periodic
			else if(mode == MODE_CIRCULAR)
			{
				if(imgCurrentPosX < 0 || imgCurrentPosX > image->numberOfRows-1)
				{
					imgCurrentPosX = mod(imgCurrentPosX,image->numberOfRows);
				}
				if(imgCurrentPosY < 0 || imgCurrentPosY > image->numberOfColumns-1)
				{
					imgCurrentPosY = mod(imgCurrentPosY,image->numberOfColumns);
				}

				pixelValue = MAT(image,imgCurrentPosX,imgCurrentPosY);
			}
	}
	//  If the postion is inside the image bound,use the current position's value
	else
	{
		pixelValue = MAT(image,imgCurrentPosX,imgCurrentPosY);
	}

	return pixelValue;

}
开发者ID:QingfengLee,项目名称:TemplateMatching,代码行数:60,代码来源:imfilter.c


示例5: mxSetField

mxArray *rmat2mx(int m, int n, rmulti **A, int LDA)
{
  const char *field_names[]={"prec","sign","exp","digits"};
  mwSize dims[2]={m,n},scalar[2]={1,1},size[2]={1,1};
  mxArray *ret=NULL,*value=NULL;
  int i,j,k;
  ret=mxCreateStructArray(2,dims,4,field_names);
  for(j=0; j<n; j++){
    for(i=0; i<m; i++){
      // prec
      value=mxCreateNumericArray(2,scalar,mxINT64_CLASS,mxREAL);
      (*(int64_t*)mxGetData(value))=MAT(A,i,j,LDA)->_mpfr_prec;
      mxSetField(ret,j*m+i,"prec",value);
      // sign
      value=mxCreateNumericArray(2,scalar,mxINT32_CLASS,mxREAL);
      (*(int32_t*)mxGetData(value))=MAT(A,i,j,LDA)->_mpfr_sign;
      mxSetField(ret,j*m+i,"sign",value);
      // exp
      value=mxCreateNumericArray(2,scalar,mxINT64_CLASS,mxREAL);
      (*(int64_t*)mxGetData(value))=MAT(A,i,j,LDA)->_mpfr_exp;
      mxSetField(ret,j*m+i,"exp",value);
      // digits
      size[1]=rget_size(MAT(A,i,j,LDA));
      value=mxCreateNumericArray(2,size,mxUINT64_CLASS,mxREAL);
      for(k=0; k<size[1]; k++){ ((uint64_t*)mxGetData(value))[k]=MAT(A,i,j,LDA)->_mpfr_d[k]; }
      mxSetField(ret,j*m+i,"digits",value);
    }
  }
  return ret;
}
开发者ID:wenxuegege,项目名称:libis,代码行数:30,代码来源:rmat2mx.c


示例6: main

int main( int argc , char *argv[] )
{
   int n,nn , ii ;
   sqrmat *KK , *AA , *AAtr, *CH ;
   double *mat, *nat , val ;

   if( argc < 2 ) exit(1) ;
   n=nn = (int)strtod(argv[1],NULL); if( nn < 2 ) exit(1);

   INIT_SQRMAT(KK,nn) ; mat = KK->mat ;
   for( ii=1 ; ii < nn ; ii++ ){
     MAT(ii,ii-1) = (double)ii ;
     MAT(ii-1,ii) = (double)(ii*ii) ;
   }
   DUMP_SQRMAT("KK",KK) ;
   val = sm_lndet_iktk(KK) ; printf("ln[det[]] = %g\n",val) ;

   AA = sm_iktk( KK ) ;
   DUMP_SQRMAT("[I-K'][I-K]",AA) ;

   ii = sm_choleski( AA ) ;
   if( ii < 1 ) exit(1) ;
   DUMP_SQRMAT("Choleski",AA) ;

   AAtr = sm_transpose(AA) ;
   CH   = sm_mult( AA , AAtr ) ;
   DUMP_SQRMAT("[Ch][Ch']",CH) ;

   exit(0) ;
}
开发者ID:LJWilliams,项目名称:Neuroimaging,代码行数:30,代码来源:sqrmat.c


示例7: igraph_i_layout_mergegrid_get_sphere

long int igraph_i_layout_mergegrid_get_sphere(igraph_i_layout_mergegrid_t *grid,
        igraph_real_t x, igraph_real_t y, igraph_real_t r) {
    long int cx, cy;
    long int i,j;
    long int ret;

    if (x-r <= grid->minx || x+r >= grid->maxx ||
            y-r <= grid->miny || y+r >= grid->maxy) {
        ret=-1;
    } else {
        igraph_i_layout_mergegrid_which(grid, x, y, &cx, &cy);

        ret=MAT(cx, cy)-1;

#define DIST(i,j) (DIST2(grid->minx+(cx+(i))*grid->deltax, \
			 grid->miny+(cy+(j))*grid->deltay))

        for (i=0; ret<0 && cx+i<grid->stepsx && DIST(i,0)<r; i++) {
            for (j=0; ret<0 && cy+j<grid->stepsy && DIST(i,j)<r; j++) {
                ret=MAT(cx+i,cy+j)-1;
            }
        }

#undef DIST
#define DIST(i,j) (DIST2(grid->minx+(cx+(i))*grid->deltax, \
                         grid->miny+(cy-(j)+1)*grid->deltay))

        for (i=0; ret<0 && cx+i<grid->stepsx && DIST(i,0)<r; i++) {
            for (j=1; ret<0 && cy-j>0 && DIST(i,j)<r; j++) {
                ret=MAT(cx+i,cy-j)-1;
            }
        }

#undef DIST
#define DIST(i,j) (DIST2(grid->minx+(cx-(i)+1)*grid->deltax, \
			 grid->miny+(cy+(j))*grid->deltay))

        for (i=1; ret<0 && cx-i>0 && DIST(i,0)<r; i++) {
            for (j=0; ret<0 && cy+j<grid->stepsy && DIST(i,j)<r; j++) {
                ret=MAT(cx-i,cy+j)-1;
            }
        }

#undef DIST
#define DIST(i,j) (DIST2(grid->minx+(cx-(i)+1)*grid->deltax, \
			 grid->miny+(cy-(j)+1)*grid->deltay))

        for (i=1; ret<0 && cx+i>0 && DIST(i,0)<r; i++) {
            for (j=1; ret<0 && cy+i>0 && DIST(i,j)<r; j++) {
                ret=MAT(cx-i,cy-j)-1;
            }
        }

#undef DIST

    }

    return ret;
}
开发者ID:huandalu,项目名称:igraph,代码行数:59,代码来源:igraph_grid.c


示例8: set_tprob_recrate

void set_tprob_recrate(hmm_t *hmm, uint32_t prev_pos, uint32_t pos, void *data)
{
    args_t *args = (args_t*) data;
    double ci = (pos - prev_pos) * args->rec_rate;
    MAT(hmm->curr_tprob,2,STATE_HW,STATE_HW) *= 1-ci;
    MAT(hmm->curr_tprob,2,STATE_HW,STATE_AZ) *= ci;
    MAT(hmm->curr_tprob,2,STATE_AZ,STATE_HW) *= ci;
    MAT(hmm->curr_tprob,2,STATE_AZ,STATE_AZ) *= 1-ci;
}
开发者ID:adeelmahmood,项目名称:alignmentportal,代码行数:9,代码来源:vcfroh.c


示例9: set_tprob_genmap

void set_tprob_genmap(hmm_t *hmm, uint32_t prev_pos, uint32_t pos, void *data)
{
    args_t *args = (args_t*) data;
    double ci = get_genmap_rate(args, pos - prev_pos, pos);
    MAT(hmm->curr_tprob,2,STATE_HW,STATE_HW) *= 1-ci;
    MAT(hmm->curr_tprob,2,STATE_HW,STATE_AZ) *= ci;
    MAT(hmm->curr_tprob,2,STATE_AZ,STATE_HW) *= ci;
    MAT(hmm->curr_tprob,2,STATE_AZ,STATE_AZ) *= 1-ci;
}
开发者ID:adeelmahmood,项目名称:alignmentportal,代码行数:9,代码来源:vcfroh.c


示例10: MATRIX_create

static CMATRIX *MATRIX_copy(CMATRIX *_object)
{
	CMATRIX *copy = MATRIX_create(WIDTH(THIS), HEIGHT(THIS), COMPLEX(THIS), FALSE);
	if (COMPLEX(THIS))
		gsl_matrix_complex_memcpy(CMAT(copy), CMAT(THIS));
	else
		gsl_matrix_memcpy(MAT(copy), MAT(THIS));
	
	return copy;
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:10,代码来源:c_matrix.c


示例11: rmat_cauchy

void rmat_cauchy(int m, int n, rmulti **A, int LDA)
{
  int i,j;
  for(j=0; j<n; j++){
    for(i=0; i<m; i++){
      rset_si(MAT(A,i,j,LDA),i+j+1);
      rinv(MAT(A,i,j,LDA),MAT(A,i,j,LDA));
    }
  }
}
开发者ID:wenxuegege,项目名称:libis,代码行数:10,代码来源:rtestmat.c


示例12: mx2cmat

void mx2cmat(int m, int n, cmulti **A, int LDA, const mxArray *src)
{
  mwSize size[2]={1,1};
  mxArray *value=NULL;
  int i,j,k;

  for(j=0; j<n; j++){
    for(i=0; i<m; i++){
      // real part
      // prec
      value=mxGetField(src,j*m+i,"r_prec");
      if(value!=NULL && mxIsInt64(value)){ rround(C_R(MAT(A,i,j,LDA)),(*(int64_t*)mxGetData(value))); }
      else{ mexErrMsgIdAndTxt("MATLAB:mx2cmat","The arg should be Struct with the feild 'prec'."); }
      // sign
      value=mxGetField(src,j*m+i,"r_sign");
      if(value!=NULL && mxIsInt32(value)){ C_R(MAT(A,i,j,LDA))->_mpfr_sign=(*(int32_t*)mxGetData(value)); }
      else{ mexErrMsgIdAndTxt("MATLAB:mx2cmat","The arg should be Struct with the feild 'sign'."); }
      // exp
      value=mxGetField(src,j*m+i,"r_exp");
      if(value!=NULL && mxIsInt64(value)){ C_R(MAT(A,i,j,LDA))->_mpfr_exp=(*(int64_t*)mxGetData(value)); }
      else{ mexErrMsgIdAndTxt("MATLAB:mx2cmat","The arg should be Struct with the feild 'exp'."); }
      // digits
      value=mxGetField(src,j*m+i,"r_digits");
      if(value!=NULL && mxIsUint64(value)){
	for(k=0; k<rget_size(C_R(MAT(A,i,j,LDA))); k++){
	  C_R(MAT(A,i,j,LDA))->_mpfr_d[k]=((uint64_t*)mxGetData(value))[k];
	}
      }
      else{ mexErrMsgIdAndTxt("MATLAB:mx2cmat","The arg should be Struct with the feild 'digits'."); }

      // imaginary part
      // prec
      value=mxGetField(src,j*m+i,"i_prec");
      if(value!=NULL && mxIsInt64(value)){ rround(C_I(MAT(A,i,j,LDA)),(*(int64_t*)mxGetData(value))); }
      else{ mexErrMsgIdAndTxt("MATLAB:mx2cmat","The arg should be Struct with the feild 'prec'."); }
      // sign
      value=mxGetField(src,j*m+i,"i_sign");
      if(value!=NULL && mxIsInt32(value)){ C_I(MAT(A,i,j,LDA))->_mpfr_sign=(*(int32_t*)mxGetData(value)); }
      else{ mexErrMsgIdAndTxt("MATLAB:mx2cmat","The arg should be Struct with the feild 'sign'."); }
      // exp
      value=mxGetField(src,j*m+i,"i_exp");
      if(value!=NULL && mxIsInt64(value)){ C_I(MAT(A,i,j,LDA))->_mpfr_exp=(*(int64_t*)mxGetData(value)); }
      else{ mexErrMsgIdAndTxt("MATLAB:mx2cmat","The arg should be Struct with the feild 'exp'."); }
      // digits
      value=mxGetField(src,j*m+i,"i_digits");
      if(value!=NULL && mxIsUint64(value)){
	for(k=0; k<rget_size(C_I(MAT(A,i,j,LDA))); k++){
	  C_I(MAT(A,i,j,LDA))->_mpfr_d[k]=((uint64_t*)mxGetData(value))[k];
	}
      }
      else{ mexErrMsgIdAndTxt("MATLAB:mx2cmat","The arg should be Struct with the feild 'digits'."); }
    }
  }
  return;
}
开发者ID:wenxuegege,项目名称:libis,代码行数:55,代码来源:mx2cmat.c


示例13: igraph_i_layout_merge_place_sphere

int igraph_i_layout_merge_place_sphere(igraph_i_layout_mergegrid_t *grid,
                                       igraph_real_t x, igraph_real_t y, igraph_real_t r,
                                       long int id) {
    long int cx, cy;
    long int i, j;

    igraph_i_layout_mergegrid_which(grid, x, y, &cx, &cy);

    MAT(cx, cy)=id+1;

#define DIST(i,j) (DIST2(grid->minx+(cx+(i))*grid->deltax, \
			 grid->miny+(cy+(j))*grid->deltay))

    for (i=0; cx+i<grid->stepsx && DIST(i,0)<r; i++) {
        for (j=0; cy+j<grid->stepsy && DIST(i,j)<r; j++) {
            MAT(cx+i,cy+j)=id+1;
        }
    }

#undef DIST
#define DIST(i,j) (DIST2(grid->minx+(cx+(i))*grid->deltax, \
                         grid->miny+(cy-(j)+1)*grid->deltay))

    for (i=0; cx+i<grid->stepsx && DIST(i,0)<r; i++) {
        for (j=1; cy-j>0 && DIST(i,j)<r; j++) {
            MAT(cx+i,cy-j)=id+1;
        }
    }

#undef DIST
#define DIST(i,j) (DIST2(grid->minx+(cx-(i)+1)*grid->deltax, \
			 grid->miny+(cy+(j))*grid->deltay))

    for (i=1; cx-i>0 && DIST(i,0)<r; i++) {
        for (j=0; cy+j<grid->stepsy && DIST(i,j)<r; j++) {
            MAT(cx-i,cy+j)=id+1;
        }
    }

#undef DIST
#define DIST(i,j) (DIST2(grid->minx+(cx-(i)+1)*grid->deltax, \
			 grid->miny+(cy-(j)+1)*grid->deltay))

    for (i=1; cx-i>0 && DIST(i,0)<r; i++) {
        for (j=1; cy-j>0 && DIST(i,j)<r; j++) {
            MAT(cx-i,cy-j)=id+1;
        }
    }

#undef DIST
#undef DIST2

    return 0;
}
开发者ID:huandalu,项目名称:igraph,代码行数:54,代码来源:igraph_grid.c


示例14: icetMatrixTranspose

void icetMatrixTranspose(const IceTDouble *matrix_in, IceTDouble *matrix_out)
{
    int rowIdx;
    for (rowIdx = 0; rowIdx < 4; rowIdx++) {
        int columnIdx;
        for (columnIdx = 0; columnIdx < 4; columnIdx++) {
            MAT(matrix_out, rowIdx, columnIdx)
                = MAT(matrix_in, columnIdx, rowIdx);
        }
    }
}
开发者ID:EricAlex,项目名称:ThirdParty-dev,代码行数:11,代码来源:matrix.c


示例15: zhouseholder_left

// B=H*A, H=I-alpha*h*h'
void zhouseholder_left(int m, int n, dcomplex *A, int LDA, int k, const dcomplex *h, double alpha)
{
  dcomplex zalpha,*p=NULL;
  p=zvec_allocate(m);
  // p=A'*h
  zvec_lintr_ct(n,m-k,p,&MAT(A,k,0,LDA),LDA,&h[k]);
  // B=H*A=A-alpha*h*(A'*h)'=A-alpha*h*p'
  Z_SET(zalpha,-alpha,0);
  zmat_rank1op(m-k,n,&MAT(A,k,0,LDA),LDA,zalpha,&h[k],p);
  // done
  p=zvec_free(p);
}
开发者ID:wenxuegege,项目名称:libis,代码行数:13,代码来源:zhshldr.c


示例16: writeFile

static bool writeFile(MAHandle fh, MAHandle data, int dataOffset, int dataLen) {
	int exists;

	MAT(exists = maFileExists(fh));
	if(exists) {
		MAT(maFileTruncate(fh, 0));
	} else {
		MAT(maFileCreate(fh));
	}
	MAT(maFileWriteFromData(fh, data, dataOffset, dataLen));
	return true;
}
开发者ID:comforx,项目名称:MoSync,代码行数:12,代码来源:setup_filesystem.c


示例17: icetMatrixMultiply

void icetMatrixMultiply(IceTDouble *C, const IceTDouble *A, const IceTDouble *B)
{
    int row, column, k;

    for (row = 0; row < 4; row++) {
        for (column = 0; column < 4; column++) {
            MAT(C, row, column) = 0.0;
            for (k = 0; k < 4; k++) {
                MAT(C, row, column) += MAT(A, row, k) * MAT(B, k, column);
            }
        }
    }
}
开发者ID:EricAlex,项目名称:ThirdParty-dev,代码行数:13,代码来源:matrix.c


示例18: idx

    vector<size_t> Other<R>::argsort(const vector<Mat<R>>& v) {
        // https://www.linux.com/news/software/developer/81090-c-the-gpu-and-thrust-sorting-numbers-on-the-gpu
        // should switch to gpu when more than 10,000 elements to sort.
        // initialize original index locations
        vector<size_t> idx(v.size());
        for (size_t i = 0; i != idx.size(); ++i) idx[i] = i;

        // sort indexes based on comparing values in v
        sort(idx.begin(), idx.end(),
           [&v](size_t i1, size_t i2) {return MAT(v[i1])(0) < MAT(v[i2])(0);});

        return idx;
    }
开发者ID:bhack,项目名称:Dali,代码行数:13,代码来源:other.cu.cpp


示例19: sm_transpose

sqrmat * sm_transpose( sqrmat *A )
{
   sqrmat *B ; int n=A->n , i,j ; double *mat,*nat ;
   INIT_SQRMAT(B,n) ;
   mat = A->mat ; nat = B->mat ;
   for( i=0 ; i < n ; i++ ){
     NAT(i,i) = MAT(i,i) ;
     for( j=0 ; j < i ; j++ ){
       NAT(i,j) = MAT(j,i) ; NAT(j,i) = MAT(i,j) ;
     }
   }
   return B ;
}
开发者ID:LJWilliams,项目名称:Neuroimaging,代码行数:13,代码来源:sqrmat.c


示例20: imfilter

struct matrix* imfilter(struct matrix* image,struct matrix* filter,uint8 operation,uint8 mode){

	float tempResult ;
	float tempPixelValue = 0.0;
	struct matrix* filteredImage = createMatrix(image->numberOfRows,image->numberOfColumns);

#ifdef DEBUG
	//For debugging initialised a temporary matrix with boundary padded
	// according to the mode given
	struct matrix* tempMatrix = createMatrix(filter->numberOfRows,filter->numberOfColumns);
#endif
	//Iterate the rows of the image
	for (uint16 i = 0; i < image->numberOfRows; ++i) {
		//Iterate the columns of the image
		for (uint16 j = 0; j < image->numberOfColumns; ++j) {
				tempResult = 0.0;
				//Iterate the rows of the filter
				for (int l = 0; l < filter->numberOfRows; ++l) {
					//Iterate the columns of the filter
					for (int m = 0; m < filter->numberOfColumns; ++m) {
						// get the pixel value for the given filter mask position(l,m)
						tempPixelValue = getPixelValue(image,i,j,l-(filter->numberOfRows/2),m-(filter->numberOfColumns/2),mode);
#ifdef DEBUG
						MAT(tempMatrix,l,m) = tempPixelValue;
#endif
						// for convolution operation the filter should be inverted
						if(operation == CONVOLUTION_OPERATION)
						{
							tempResult = tempResult + (tempPixelValue * MAT(filter,(filter->numberOfRows-1-l),(filter->numberOfColumns-1-m)));
						}
						// for correlation the filter should be used as it is
						else
						{
							tempResult = tempResult + (tempPixelValue * MAT(filter,l,m));
						}
					}
				}
#ifdef DEBUG
				printMatrix(tempMatrix);
#endif
				MAT(filteredImage,i,j) = tempResult;

		}
	}

#ifdef DEBUG
	printMatrix(filteredImage);
#endif

	return filteredImage;
}
开发者ID:QingfengLee,项目名称:TemplateMatching,代码行数:51,代码来源:imfilter.c



注:本文中的MAT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MATCH函数代码示例发布时间:2022-05-30
下一篇:
C++ MASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap