IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34800 for trunk/psLib


Ignore:
Timestamp:
Dec 11, 2012, 2:04:31 PM (14 years ago)
Author:
watersc1
Message:

Merge from my branch including background restoration and stack stage projection cell binned images.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psLib/src/imageops/psImageInterpolate.c

    r34365 r34800  
    3131#include "psImageConvolve.h"
    3232
    33 # define IS_BILIN_SEPARABLE 0
     33# define IS_BILIN_SEPARABLE 1
    3434
    3535#include "psImageInterpolate.h"
     
    189189    switch (mode) {
    190190      case PS_INTERPOLATE_FLAT:
     191      case PS_INTERPOLATE_BILINEAR_SIMPLE:
    191192        // Nothing to pre-compute
    192193        break;
     
    287288# endif
    288289      case PS_INTERPOLATE_BIQUADRATIC:
     290      case PS_INTERPOLATE_BILINEAR_SIMPLE:
    289291        // 2D kernel, would cost too much memory to pre-calculate
    290292        break;
     293
    291294      default:
    292295        psAbort("Unsupported interpolation mode: %x", mode);
     
    937940
    938941
     942psImageInterpolateStatus interpolateJustWork(double *imageValue, double *varianceValue,
     943                                             psImageMaskType *maskValue, float x, float y,
     944                                             const psImageInterpolation *interp) {
     945  float u1,u2;
     946  int xl,xh;
     947  int yl,yh;
     948  const psImage *image = interp->image; // Image to interpolate
     949
     950  xl = floor(x);
     951  if (xl < 0) { xl = 0; }
     952  if (xl >= image->numCols) {xl = image->numCols - 1; }
     953  xh = xl + 1;
     954  if (xh >= image->numCols) {xh = image->numCols - 1; }
     955
     956  yl = floor(y);
     957  if (yl < 0) { yl = 0; }
     958  if (yl >= image->numRows) {yl = image->numRows - 1; }
     959  yh = yl + 1;
     960  if (yh >= image->numRows) {yh = image->numRows - 1; }
     961
     962  if (imageValue && image) {
     963    if (image->data.F32[yl][xl] == image->data.F32[yl][xh]) {
     964      u1 = image->data.F32[yl][xh];
     965    }
     966    else {
     967      u1 = (xh - x) * image->data.F32[yl][xl] + (x - xl) * image->data.F32[yl][xh];
     968    }
     969    if (image->data.F32[yh][xl] == image->data.F32[yh][xh]) {
     970      u2 = image->data.F32[yh][xh];
     971    }
     972    else {
     973      u2 = (xh - x) * image->data.F32[yh][xl] + (x - xl) * image->data.F32[yh][xh];
     974    }
     975    if (u1 == u2) {
     976      *imageValue = u1;
     977    }
     978    else {
     979      *imageValue = (yh - y) * u1 + (y - yl) * u2;
     980    }
     981    if ((floor(x) >= image->numCols)||
     982        (floor(y) >= image->numRows)) {
     983      *imageValue = NAN;
     984    }
     985  }
     986#if (0)
     987  if (*imageValue == 0.0) {
     988    fprintf(stderr,"IJK: Zero!: %g %g [%d %d %d %d] %g %g (%g %g %g %g)\n",
     989            x,y,xl,xh,yl,yh,u1,u2,
     990            image->data.F32[yl][xl],image->data.F32[yl][xh],image->data.F32[yh][xl],image->data.F32[yh][xh]
     991            );
     992  }
     993#endif
     994  return PS_INTERPOLATE_STATUS_GOOD;
     995}
     996 
    939997
    940998psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue,
     
    9691027      case PS_INTERPOLATE_BIQUADRATIC:
    9701028        return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);
     1029      case PS_INTERPOLATE_BILINEAR_SIMPLE:
     1030        return interpolateJustWork(imageValue, varianceValue, maskValue, x, y, interp);
    9711031      case PS_INTERPOLATE_BILINEAR:
    9721032# if (!IS_BILIN_SEPARABLE)
    973         return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);
     1033        return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);
    9741034# endif
    9751035      case PS_INTERPOLATE_GAUSS:
     
    10191079    switch (mode) {
    10201080      case PS_INTERPOLATE_FLAT:
     1081      case PS_INTERPOLATE_BILINEAR_SIMPLE:
    10211082        // No smearing by design
    10221083        return 1.0;
     
    10831144    if (!strcasecmp(name, "FLAT"))     return PS_INTERPOLATE_FLAT;
    10841145    if (!strcasecmp(name, "BILINEAR")) return PS_INTERPOLATE_BILINEAR;
     1146    if (!strcasecmp(name, "SIMPLEBILINEAR")) return PS_INTERPOLATE_BILINEAR_SIMPLE;
    10851147    if (!strcasecmp(name, "BIQUADRATIC")) return PS_INTERPOLATE_BIQUADRATIC;
    10861148    if (!strcasecmp(name, "GAUSS"))    return PS_INTERPOLATE_GAUSS;
  • trunk/psLib/src/imageops/psImageInterpolate.h

    r21281 r34800  
    3333    PS_INTERPOLATE_LANCZOS3,            ///< Sinc interpolation with 6x6 pixel kernel
    3434    PS_INTERPOLATE_LANCZOS4,            ///< Sinc interpolation with 8x8 pixel kernel
     35    PS_INTERPOLATE_BILINEAR_SIMPLE,     ///< Simple manual bilinear interpolation
    3536} psImageInterpolateMode;
    3637
  • trunk/psLib/src/imageops/psImagePixelManip.c

    r12953 r34800  
    216216    }
    217217
    218 
     218#define psImageOverlayLoopClean(DATATYPE,OP) {   \
     219      for (int row=y0;row<imageRowLimit;row++) {            \
     220        ps##DATATYPE* imageRow = image->data.DATATYPE[row];        \
     221        ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-y0]; \
     222        for (int col=x0;col<imageColLimit;col++) {                 \
     223          if (!isfinite(imageRow[col])) {                          \
     224            imageRow[col] OP overlayRow[col-x0];                   \
     225          }                                                        \
     226          else if (!isfinite(overlayRow[col-x0])) {                \
     227            imageRow[col] = imageRow[col];                         \
     228          }                                                        \
     229          else {                                                   \
     230            imageRow[col] = overlayRow[col-x0];                    \
     231          }                                                             \
     232        }                                                               \
     233      }                                                                 \
     234      pixelsOverlaid += (imageRowLimit - y0) * (imageColLimit - x0);    \
     235    }
     236
     237#define psImageOverlayLoopMask(DATATYPE) {                  \
     238      for (int row=y0;row<imageRowLimit;row++) {            \
     239        ps##DATATYPE* imageRow = image->data.DATATYPE[row];        \
     240        ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-y0]; \
     241        for (int col=x0;col<imageColLimit;col++) {                 \
     242          if (!isfinite(imageRow[col])) {                          \
     243            imageRow[col] = overlayRow[col-x0];            \
     244          }                                                        \
     245          else if (!isfinite(overlayRow[col-x0])) {                \
     246            imageRow[col] = imageRow[col];                         \
     247          }                                                        \
     248          else {                                                   \
     249            imageRow[col] &= overlayRow[col-x0];                   \
     250          }                                                             \
     251        }                                                               \
     252      }                                                                 \
     253      pixelsOverlaid += (imageRowLimit - y0) * (imageColLimit - x0);    \
     254    }
     255       
     256   
     257   
    219258    #define psImageOverlayLoop(DATATYPE,OP) { \
    220259        for (int row=y0;row<imageRowLimit;row++) { \
    221260            ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \
    222261            ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-y0]; \
    223             for (int col=x0;col<imageColLimit;col++) { \
    224                 imageRow[col] OP overlayRow[col-x0]; \
    225             } \
    226         } \
     262            for (int col=x0;col<imageColLimit;col++) {                \
     263                imageRow[col] OP overlayRow[col-x0];                  \
     264              }                                                        \
     265        }                                                              \
    227266        pixelsOverlaid += (imageRowLimit - y0) * (imageColLimit - x0); \
    228     }
     267      }
    229268
    230269    #define psImageOverlayLoopDivide(DATATYPE,BADVALUE) { \
     
    273312        psImageOverlayLoop(DATATYPE,*=); \
    274313        break; \
     314    case 'E': \
     315      psImageOverlayLoopClean(DATATYPE,=); \
     316      break;                               \
    275317    case '/': \
    276318        psImageOverlayLoopDivide(DATATYPE,BADVALUE); \
    277319        break; \
    278320    case '=': \
    279         psImageOverlaySetLoop(DATATYPE); \
     321        psImageOverlaySetLoop(DATATYPE);                \
    280322        break; \
    281323    default: \
     
    286328    } \
    287329    break;
     330    #define psImageOverlayCaseInt(DATATYPE,BADVALUE) \
     331case PS_TYPE_##DATATYPE: \
     332    switch (*op) { \
     333    case '+': \
     334        psImageOverlayLoop(DATATYPE,+=); \
     335        break; \
     336    case '-': \
     337        psImageOverlayLoop(DATATYPE,-=); \
     338        break; \
     339    case '*': \
     340        psImageOverlayLoop(DATATYPE,*=); \
     341        break; \
     342    case 'E': \
     343      psImageOverlayLoopClean(DATATYPE,=); \
     344      break;                               \
     345    case 'M':                              \
     346      psImageOverlayLoopMask(DATATYPE);    \
     347      break;                               \
     348    case '/': \
     349        psImageOverlayLoopDivide(DATATYPE,BADVALUE); \
     350        break; \
     351    case '=': \
     352        psImageOverlaySetLoop(DATATYPE);                \
     353        break; \
     354    default: \
     355        psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     356                _("Specified operation, '%s', is not supported."), \
     357                op); \
     358        return pixelsOverlaid; \
     359    } \
     360    break;
    288361
    289362    switch (type) {
    290         psImageOverlayCase(U8, 0);
    291         psImageOverlayCase(U16,0);
    292         psImageOverlayCase(U32,0);       // Not a requirement
    293         psImageOverlayCase(U64,0);       // Not a requirement
    294         psImageOverlayCase(S8, 0);
    295         psImageOverlayCase(S16,0);
    296         psImageOverlayCase(S32,0);       // Not a requirement
    297         psImageOverlayCase(S64,0);       // Not a requirement
     363        psImageOverlayCaseInt(U8, 0);
     364        psImageOverlayCaseInt(U16,0);
     365        psImageOverlayCaseInt(U32,0);       // Not a requirement
     366        psImageOverlayCaseInt(U64,0);       // Not a requirement
     367        psImageOverlayCaseInt(S8, 0);
     368        psImageOverlayCaseInt(S16,0);
     369        psImageOverlayCaseInt(S32,0);       // Not a requirement
     370        psImageOverlayCaseInt(S64,0);       // Not a requirement
    298371        psImageOverlayCase(F32,NAN);
    299372        psImageOverlayCase(F64,NAN);
Note: See TracChangeset for help on using the changeset viewer.