(file) Return to imageinterp.c CVS log (file) (dir) Up to [Development] / JSOC / proj / globalhs / apps

Diff for /JSOC/proj/globalhs/apps/imageinterp.c between version 1.2 and 1.4

version 1.2, 2011/08/16 02:29:10 version 1.4, 2013/05/03 20:47:15
Line 36 
Line 36 
  */  */
  
 #include <math.h> #include <math.h>
 //#include "astro.h"  #include "projection.h"
  
 typedef struct LIBASTRO_Dist_Struct  char *cvsinfo_imageinterp = "cvsinfo: $Header$";
 {  
   int disttype;  
   double scale; /* Image scale relative to FD. 5 for vw. */  
   double xc, yc; /* Nominal image center in pixels. */  
   double cdist; /* Cubic distortion constant for FD images */  
   double feff, alpha, cosbeta, sinbeta; /* Tilt constants for FD. */  
 } LIBASTRO_Dist_t;  
   
 typedef enum  
 {  
    kLIBASTRO_InterBilinear = 0,  
    kLIBASTRO_InterCubic = 1,  
 } LIBASTRO_Interpolation_t;  
   
 typedef enum  
 {  
    kLIBASTRO_Success = 0,  
    kLIBASTRO_BadDimensionality,  
    kLIBASTRO_BadData,  
    kLIBASTRO_CouldntCreateData,  
    kLIBASTRO_DimensionMismatch,  
    kLIBASTRO_CantDoOddNumLats,  
    kLIBASTRO_UnsupportedInterp,  
    kLIBASTRO_UnsupportedMCOR,  
    kLIBASTRO_UnsupportedVCOR,  
    kLIBASTRO_InconsistentConstraints,  
    kLIBASTRO_InvalidArgs,  
    kLIBASTRO_Interpolation,  
    kLIBASTRO_InsufficientData  
 } LIBASTRO_Error_t;  
  
 const int kMaxCols = 8192; const int kMaxCols = 8192;
 const double kOmegaCarr = (360 /  27.27527); /* degrees/day - synodic Carrington rotation rate */ const double kOmegaCarr = (360 /  27.27527); /* degrees/day - synodic Carrington rotation rate */
Line 83  static void Distort(double x,
Line 53  static void Distort(double x,
                     int sign,                     int sign,
                     double *xd,                     double *xd,
                     double *yd,                     double *yd,
                     const LIBASTRO_Dist_t *distpars);                      const LIBPROJECTION_Dist_t *distpars);
  
 /* Calculate the interpolation kernel. */ /* Calculate the interpolation kernel. */
 void Ccker(double *u, double s) void Ccker(double *u, double s)
Line 191  int SetDistort(int dist,
Line 161  int SetDistort(int dist,
                double alpha,                double alpha,
                double beta,                double beta,
                double feff,                double feff,
                LIBASTRO_Dist_t *dOut)                 LIBPROJECTION_Dist_t *dOut)
 { {
    int error = 0;    int error = 0;
  
Line 256  void Distort(double x,
Line 226  void Distort(double x,
              int sign,              int sign,
              double *xd,              double *xd,
              double *yd,              double *yd,
              const LIBASTRO_Dist_t *distpars)               const LIBPROJECTION_Dist_t *distpars)
 { {
    /*    /*
      For sign=+1 transforms ideal coordinates (x,y) to distorted      For sign=+1 transforms ideal coordinates (x,y) to distorted
Line 333  int imageinterp(
Line 303  int imageinterp(
         double   P,  /* angle between CCD y-axis and solar vertical */         double   P,  /* angle between CCD y-axis and solar vertical */
                      /* positive to the east (CCW) */                      /* positive to the east (CCW) */
         double   rsun,  /* pixels */         double   rsun,  /* pixels */
           double   Rmax, /* maximum disk radius to use (e.g. 0.95)        */
           int      NaN_beyond_rmax,
         int interpolation, /* option */         int interpolation, /* option */
         int cols,  /* width of output array   */         int cols,  /* width of output array   */
         int rows,  /* height of output array   */         int rows,  /* height of output array   */
         double   vsign,         double   vsign,
         const LIBASTRO_Dist_t *distpars)          const LIBPROJECTION_Dist_t *distpars)
 { {
  
    float u;   /* output temp    */    float u;   /* output temp    */
    double x, y;   /* CCD location of desired point */    double x, y;   /* CCD location of desired point */
    int row, col;   /* index into output array  */    int row, col;   /* index into output array  */
    int rowoffset;    int rowoffset;
    double xratio, yratio;     double xratio, yratio, Rmax2;
  
    long i;    long i;
    double *vdp;    double *vdp;
Line 358  int imageinterp(
Line 329  int imageinterp(
    vp=V;    vp=V;
    for (i=0;i<xpixels*ypixels;i++) *vdp++=(double)*vp++;    for (i=0;i<xpixels*ypixels;i++) *vdp++=(double)*vp++;
  
      Rmax2 = Rmax*Rmax*rsun*rsun;
   
    if (cols > kMaxCols)    if (cols > kMaxCols)
    {    {
       return kLIBASTRO_DimensionMismatch;        return kLIBPROJECTION_DimensionMismatch;
    }    }
  
  
    if (interpolation != kLIBASTRO_InterCubic && interpolation != kLIBASTRO_InterBilinear)     if (interpolation != kLIBPROJECTION_InterCubic && interpolation != kLIBPROJECTION_InterBilinear)
    {    {
       return kLIBASTRO_UnsupportedInterp;        return kLIBPROJECTION_UnsupportedInterp;
    }    }
  
    xratio=(double)xpixels/cols;    xratio=(double)xpixels/cols;
Line 378  int imageinterp(
Line 351  int imageinterp(
  
       for (col = 0; col < cols; col++) {       for (col = 0; col < cols; col++) {
  
          xtmp=col*xratio - x0;           xtmp = (col + 0.5)*xratio - 0.5 - x0;
          ytmp=row*yratio - y0;           ytmp = (row + 0.5)*yratio - 0.5 - y0;
          x= x0 + xtmp*cos(P) + ytmp*sin(P);           if ((xtmp*xtmp + ytmp*ytmp) >= Rmax2)
          y= y0 - xtmp*sin(P) + ytmp*cos(P);           {
              *(U + rowoffset + col) = (NaN_beyond_rmax) ? DRMS_MISSING_FLOAT : (float)0.0;
              continue;
            }
            x= x0 + xtmp*cos(P) - ytmp*sin(P);
            y= y0 + xtmp*sin(P) + ytmp*cos(P);
  
          Distort(x, y, rsun, +1, &x, &y, distpars);          Distort(x, y, rsun, +1, &x, &y, distpars);
  
          if (interpolation == kLIBASTRO_InterCubic)           if (interpolation == kLIBPROJECTION_InterCubic)
          {          {
             u = (float)(vsign * Ccintd (VD,xpixels,ypixels,x,y));             u = (float)(vsign * Ccintd (VD,xpixels,ypixels,x,y));
          }          }
          else if (interpolation == kLIBASTRO_InterBilinear)           else if (interpolation == kLIBPROJECTION_InterBilinear)
          {          {
             u = (float)(vsign * Linintd (VD,xpixels,ypixels,x,y));             u = (float)(vsign * Linintd (VD,xpixels,ypixels,x,y));
          }          }
Line 398  int imageinterp(
Line 376  int imageinterp(
       }       }
    }    }
    free(VD);    free(VD);
    return kLIBASTRO_Success;     return kLIBPROJECTION_Success;
 } }


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

Karen Tian
Powered by
ViewCVS 0.9.4