예제 #1
0
void			resample( double *A, double *B, int ha, int hb, int w, int nCh ) {
  /* resample every column in A, store in B, result is transposed */
  int ch, x, y, n; double *a, *b; const bool downsample=(hb<=ha); InterpInfo *ii;
  if(downsample) ii=interpInfoDn(ha, hb, &n); else ii=interpInfoUp(ha, hb, &n);
  for(x=0; x<n; x++) ii[x].yb*=w; /* transpose B */
  for(ch=0; ch<nCh; ch++) for(x=0; x<w; x++) {
    a = A + ch*w*ha + x*ha;
    b = B + ch*w*hb + x;
    if( downsample )
      for(y=0; y<n; y++) b[ii[y].yb]+=ii[y].wt0*a[ii[y].ya0];
    else
      for(y=0; y<n; y++) b[ii[y].yb]=a[ii[y].ya0]*ii[y].wt0+a[ii[y].ya1]*ii[y].wt1;
  }
  mxFree(ii);
}
예제 #2
0
파일: imResample1.c 프로젝트: notPriya/LKT
void			resample( double *A, double *B, int dim, int m0, int m1, int n, int nCh ) {
  /* resample along dim in A, store in B */
  int ch, x, y, r; double *a, *a0, *a1, *b, *b0, wt0, wt1;
  const bool downsample=(m1<m0); InterpInfo *ii;
  if(downsample) ii=interpInfoDn(m0, m1, &r); else ii=interpInfoUp(m0, m1, &r);
  if(dim==1) for(y=0; y<r; y++) { ii[y].yb*=n; ii[y].ya0*=n; ii[y].ya1*=n; }
  for(ch=0; ch<nCh; ch++) {
    a=A+ch*n*m0; b=B+ch*n*m1;
	/* resample height m0->m1 (width n unchanged) */
    if(dim==0) for(x=0; x<n; x++) {
      a0=a+x*m0; b0=b+x*m1;
      if( downsample ) for(y=0; y<r; y++) b0[ii[y].yb] += a0[ii[y].ya0]*ii[y].wt0;
      else for(y=0; y<r; y++) b0[ii[y].yb] = a0[ii[y].ya0]*ii[y].wt0 + a0[ii[y].ya1]*ii[y].wt1;
    /* resample width m0->m1 (height n unchanged) */
    } else for(x=0; x<r; x++) {
      a0=a+ii[x].ya0; a1=a+ii[x].ya1; b0=b+ii[x].yb; wt0=ii[x].wt0; wt1=ii[x].wt1;
      if( downsample ) for(y=0; y<n; y++) b0[y] += a0[y]*wt0;
      else for(y=0; y<n; y++) b0[y] = a0[y]*wt0 + a1[y]*wt1;
    }
  }
  mxFree(ii);
}