IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 18, 2007, 3:39:28 PM (19 years ago)
Author:
Paul Price
Message:

Adding GUNK (Grid United with Normal Kernels --- a POIS/ISIS hybrid) kernels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r14304 r14305  
    44 *  @author GLG, MHPCC
    55 *
    6  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-07-19 01:10:57 $
     6 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-07-19 01:39:28 $
    88 *
    99 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    2525#include "pmSubtraction.h"
    2626
    27 //#define USE_FUNCTIONS_INSTEAD_OF_MACROS          // Can I pass the address of a static inline function?
     27#define USE_FUNCTIONS_INSTEAD_OF_MACROS          // Can I pass the address of a static inline function?
    2828
    2929//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    209209              break;
    210210          }
     211          case PM_SUBTRACTION_KERNEL_GUNK: {
     212              if (i < kernels->inner) {
     213                  // Using pre-calculated function
     214                  psKernel *preCalc = kernels->preCalc->data[i]; // Precalculated values
     215                  for (int v = -size; v <= size; v++) {
     216                      for (int u = -size; u <= size; u++) {
     217                          kernel->kernel[v][u] += value * weightFunc(preCalc->kernel[v][u]);
     218                      }
     219                  }
     220              } else {
     221                  // Using delta function
     222                  int u = kernels->u->data.S32[i]; // Offset in x
     223                  int v = kernels->v->data.S32[i]; // Offset in y
     224                  kernel->kernel[v][u] += value;
     225              }
     226              // The (0,0) kernel is subtracted from other kernels to preserve photometric scaling
     227              if (kernels->spatialOrder > 0 && i != kernels->subIndex) {
     228                  kernel->kernel[0][0] += subValue;
     229              }
     230              break;
     231          }
    211232          case PM_SUBTRACTION_KERNEL_ISIS: {
    212233              psKernel *preCalc = kernels->preCalc->data[i];// Precalculated values
     
    355376          return sum;
    356377      }
     378      case PM_SUBTRACTION_KERNEL_GUNK: {
     379          double value;                 // The value to return
     380          if (index < kernels->inner) {
     381              // Using pre-calculated function
     382              psKernel *kernel = kernels->preCalc->data[index]; // The convolution kernel
     383              int size = kernels->size;     // Kernel half-size
     384              double sum = 0.0;             // Accumulated sum from convolution
     385              double sub = 0.0;             // Accumulated sum to subtract
     386              for (int v = -size; v <= size; v++) {
     387                  for (int u = -size; u <= size; u++) {
     388                      sum += weightFunc(kernel->kernel[v][u]) * image->data.F32[y + v][x + u];
     389                  }
     390              }
     391              value = weightFunc(polyValue) * sum + weightFunc(-1.0) * sub;
     392          } else {
     393              // Using delta function
     394              int u = kernels->u->data.S32[index]; // Offset in x
     395              int v = kernels->v->data.S32[index]; // Offset in y
     396              value = weightFunc(polyValue) * image->data.F32[y + v][x + u]; // Value of convolution
     397          }
     398          /* The (0,0) delta function is subtracted from most kernels to preserve photometric scaling */
     399          if (kernels->spatialOrder > 0 && index != kernels->subIndex) {
     400              value += weightFunc(-1.0) * image->data.F32[y][x];
     401          }
     402          return value;
     403      }
    357404      case PM_SUBTRACTION_KERNEL_ISIS: {
    358405          psKernel *kernel = kernels->preCalc->data[index]; // The convolution kernel
Note: See TracChangeset for help on using the changeset viewer.