IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 3, 2013, 4:21:05 PM (13 years ago)
Author:
watersc1
Message:

Working 1D-Gaussian convolution code. Recipes/reductions that use this have _1DG added.

File:
1 edited

Legend:

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

    r30622 r35771  
    6565    return result;
    6666}
     67
     68// Generate 1D convolution kernel for SIMPLE
     69psVector *pmSubtractionKernelSIMPLE(float sigma, // Gaussian width
     70                                    int order,   // Unused polynomial order
     71                                    int size     // Kernel half-size
     72                                    )
     73{
     74  int fullSize = 2 * size + 1;    // Full size of the kernel
     75  psVector *kernel = psVectorAlloc(fullSize, PS_TYPE_F32); // Kernel to return
     76  float expNorm = -0.5 / PS_SQR(sigma); // Normalization for exponential
     77  float norm    = 1.0 / sqrtf(2.0 * M_PI * sigma * sigma); // Correct Normalization for Gaussian
     78  if (sigma < 0.1) {
     79    kernel->data.F32[size] = 1.0;
     80    return(kernel);
     81  }
     82  for (int i = 0, x = -size; x <= size; i++,x++) {
     83    kernel->data.F32[i] = norm * expf(expNorm * PS_SQR(x));
     84  }
     85  return(kernel);
     86}
     87
    6788
    6889// Generate 1D convolution kernel for ISIS
     
    771792        preCalc->poly    = NULL;
    772793        break;
     794    case PM_SUBTRACTION_KERNEL_SIMPLE:
     795      preCalc->xKernel = pmSubtractionKernelSIMPLE(sigma,uOrder,size);
     796      preCalc->yKernel = pmSubtractionKernelSIMPLE(sigma,vOrder,size);
     797      preCalc->uCoords = NULL;
     798      preCalc->vCoords = NULL;
     799      preCalc->poly    = NULL;
     800      break;
    773801      case PM_SUBTRACTION_KERNEL_RINGS:
    774802        // the RINGS kernel uses the uCoords, vCoords, and poly elements of the structure
     
    12301258      case PM_SUBTRACTION_KERNEL_RINGS:
    12311259        return pmSubtractionKernelsRINGS(size, spatialOrder, inner, ringsOrder, penalty, bounds, mode);
     1260    case PM_SUBTRACTION_KERNEL_SIMPLE:
     1261      return pmSubtractionKernelsISIS(size,spatialOrder,fwhms,orders,penalty,bounds,mode);
    12321262      default:
    12331263        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unknown kernel type: %x", type);
     
    12981328      case PM_SUBTRACTION_KERNEL_HERM:
    12991329      case PM_SUBTRACTION_KERNEL_DECONV_HERM:
     1330    case PM_SUBTRACTION_KERNEL_SIMPLE:
    13001331        PARSE_STRING_NUMBER(size, ptr, ',', parseStringInt);
    13011332
     
    13791410        return PM_SUBTRACTION_KERNEL_RINGS;
    13801411    }
    1381 
     1412    if (strncasecmp(type, "SIMPLE", nameLength) == 0) {
     1413      return PM_SUBTRACTION_KERNEL_SIMPLE;
     1414    }
    13821415    psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised kernel type: %s", type);
    13831416    return PM_SUBTRACTION_KERNEL_NONE;
     
    14361469        break;
    14371470
     1471    case PM_SUBTRACTION_KERNEL_SIMPLE:
     1472      psStringAppend(&kernels->description, "SIMPLE(%d,%s)",kernels->size,params);
     1473      break;
    14381474      default:
    14391475        psAbort("unknown kernel");
Note: See TracChangeset for help on using the changeset viewer.