#include #include #include #include "nrutil.h" //y is the input image, nx and ny are the pixels along x and y axis; //yt and residu are the required matrix for the function //para contains the needed parameters: centx=para[3], centy=para[4] void star_gaus(float **y,int nx,int ny,double *para); void Interp_bicubic(int nx,int ny,float **a0,int nbound, int nxt,int nyt, float **at,double *xcen); void splie2(float **ya, int m, int n, float **y2a); void spline(float y[], int n, float yp1, float ypn, float y2[]); void splint(float ya[], float y2a[], int n, float x, float *y); void centroidWgt(float *y, int nx, int ny, double *para) { int i, j, k; float **yy; double **basef; double **coff; double ccol, crow; yy = matrix(0, nx-1, 0, ny-1); for(i=0; iy[i])ymin=y[i]; } kc=ymax;kd=ymax/12.; det=ysigma=kc*exp(-0.5); for(i=0;i0){ for(j=-4;j<=4;j++){ sigma=sigmac+j*sigmad; if(sigma>0){ sigma2v=-1./(2.*sigma*sigma); for(p=-4;p<=4;p++){ xt=xc+p*xd; for(q=-4;q<=4;q++){ yt=yc+q*yd; k2=0; if(fbg==0){ bg=bg0; for(m=0;m //#include //#include //#include "nrutil.h" //nx,ny is the pixels of x and y direction //a0 is the input image in nx*ny //nbound is the boundary limit //nxt,nyt is out put image dimentions //at is the output image and cen represent the required center void Interp_bicubic(int nx,int ny,float **a0,int nbound, int nxt,int nyt, float **at,double *xcen) { void splie2(float **ya, int m, int n, float **y2a); void spline(float y[], int n, float yp1, float ypn, float y2[]); void splint(float ya[], float y2a[], int n, float x, float *y); int i,j,m,n,ic,jc; float *ytmp,*yytmp,**y2a,x1,x2,shift1,shift2; y2a=matrix(0,nx,0,ny); ytmp=vector(0,ny); yytmp=vector(0,ny); splie2(a0,nx,ny,y2a); ic=nx*0.5; jc=ny*0.5; shift1=xcen[0]-ic;//-0.5; shift2=xcen[1]-jc;//-0.5; if(fabs(shift1)>nbound || fabs(shift2)>nbound){ printf("bicubic shifts too much %e %e\n",shift1,shift2); getchar(); } for (n=0;n 0.99e30) y2[0]=u[0]=0.0; else { y2[0] = -0.5; u[0]=3.0*(y[1]-y[0]-yp1); } sig=0.5; for (i=1;i<=n-2;i++) { p=sig*y2[i-1]+2.0; y2[i]=(sig-1.0)/p; u[i]=(y[i+1]-2.*y[i]+y[i-1]); u[i]=(3.0*u[i]-sig*u[i-1])/p; } if (ypn > 0.99e30) qn=un=0.0; else { qn=0.5; un=3.0*(ypn-y[n-1]+y[n-2]); } y2[n-1]=(un-qn*u[n-2])/(qn*y2[n-2]+1.0); for (k=n-2;k>=0;k--)y2[k]=y2[k]*y2[k+1]+u[k]; free_vector(u,0,n-1); } void splint(float ya[], float y2a[], int n, float x, float *y) { void nrerror(char error_text[]); int klo,khi,k; float h,b,a; klo=x; if( klo<0)klo=0; if(klo==n-1)klo=n-2; khi=klo+1; if (klo<0 || khi>=n) printf("error:klo, khi, n: %d %d %d\n", klo, khi, n); if (klo<0 || khi>=n) nrerror("Bad xa input to routine splint"); a=(khi-x); b=(x-klo); *y=a*ya[klo]+b*ya[khi]+((a*a*a-a)*y2a[klo]+(b*b*b-b)*y2a[khi])/6.0; }