IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36228


Ignore:
Timestamp:
Oct 22, 2013, 6:27:11 AM (13 years ago)
Author:
eugene
Message:

renaming psImageSmooth_PreAlloc stuff to psImageSmoothCache; setting up for arbitrary shapes

Location:
branches/eam_branches/ipp-20130904
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/psLib/src/imageops/psImageConvolve.c

    r35767 r36228  
    780780}
    781781
    782 void psImageSmooth_PreAlloc_DataFree (psImageSmooth_PreAlloc_Data *smdata) {
     782void psImageSmoothCacheDataFree (psImageSmoothCacheData *smdata) {
    783783    psFree (smdata->resultX);
    784784    psFree (smdata->resultY);
     
    786786}
    787787
    788 psImageSmooth_PreAlloc_Data *psImageSmooth_PreAlloc_DataAlloc (psImage *image, double sigma, double Nsigma) {
     788// allocate the psImageSmoothCache data structure, but do not define the kernel
     789psImageSmoothCacheData *psImageSmoothCacheAlloc (psImage *image, double sigma, double Nsigma) {
    789790
    790791    psImageSmooth_PreAlloc_Data *smdata = psAlloc(sizeof(psImageSmooth_PreAlloc_Data));
     
    807808    smdata->Ny = image->numRows;            // Number of rows
    808809
    809     IMAGE_SMOOTH_GAUSS(smdata->kernel, smdata->Nrange, sigma, F32);
     810    // IMAGE_SMOOTH_GAUSS(smdata->kernel, smdata->Nrange, sigma, F32);
    810811       
    811812    // use a temp running buffer for X and Y directions.
     
    819820}
    820821
     822// generate a Gaussian smoothing kernel for supplied sigma.  sigma here does not need to match
     823// that used to allocate the structure, but it is recommended
     824bool psImageSmoothCacheKernel_Gauss (psImageSmoothCacheData *smdata, float sigma) {
     825    // check for NULL structure elements?
     826    IMAGE_SMOOTH_GAUSS(smdata->kernel, smdata->Nrange, sigma, F32);
     827    return true;
     828}
     829
    821830// we can use the same DATA structure on multiple images of the same size
    822 bool psImageSmooth_PreAlloc_F32(psImage *image, psImageSmooth_PreAlloc_Data *smdata)
     831bool psImageSmoothCache_F32(psImage *image, psImageSmoothCacheData *smdata)
    823832{
    824833    PS_ASSERT_IMAGE_NON_NULL(image, false);
     834    PS_ASSERT_KERNEL_NON_NULL(smdata->kernel, false);
    825835    // assert on data type
    826836
  • branches/eam_branches/ipp-20130904/psLib/src/imageops/psImageConvolve.h

    r35767 r36228  
    2626#define PS_TYPE_KERNEL_NAME "psF32"    ///< the data type for kernel as a string */
    2727
    28 /// a structure to contain data related to image smoothing with a 1D gauss kernel
     28/// a structure to contain data related to image smoothing with a pre-cached 1D gauss kernel
    2929typedef struct {
    3030    int Nx;
     
    3434    psF32 *resultY;
    3535    psVector *kernel;
    36 } psImageSmooth_PreAlloc_Data;
     36} psImageSmoothCacheData;
    3737
    3838/// A convolution kernel
     
    306306);
    307307
    308 psImageSmooth_PreAlloc_Data *psImageSmooth_PreAlloc_DataAlloc (psImage *image, double sigma, double Nsigma);
    309 bool psImageSmooth_PreAlloc_F32(psImage *image, psImageSmooth_PreAlloc_Data *smdata);
     308psImageSmoothCacheData *psImageSmoothCacheAlloc (psImage *image, double sigma, double Nsigma);
     309bool psImageSmoothCache_F32(psImage *image, psImageSmoothCacheData *smdata);
    310310
    311311/// Control threading for image convolution functions
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCM_MinimizeChisq.c

    r36204 r36228  
    581581
    582582            float ymodel  = pcm->modelConvFlux->data.F32[i][j];
     583
     584            // XXXX note this point here:::
    583585            float yweight = 1.0 / source->variance->data.F32[i][j];
    584586            float delta = ymodel - source->pixels->data.F32[i][j];
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCMdata.c

    r36207 r36228  
    248248}
    249249
     250// generate a Gaussian smoothing kernel for supplied sigma.  sigma here does not need to match
     251// that used to allocate the structure, but it is recommended
     252bool psImageSmoothCacheKernel_PS1_V1 (psImageSmoothCacheData *smdata, float sigma, float kappa) {
     253    // check for NULL structure elements?
     254
     255    int size = smdata->Nrange + 1;
     256
     257    smdata->kernel = psVectorAlloc(2 * smdata->Nrange + 1, PS_TYPE_F32);
     258
     259    double sum = 0.0;                   // Sum of Gaussian, for normalization
     260    double factor = 1.0 / (sigma * M_SQRT2);    // Multiplier for i -> z
     261
     262    // PS1_V1 is a power-law with fitted linear term:
     263    // 1 / (1 + kappa z + z^1.666)  where z = (r/sigma)^2
     264
     265    // generate the kernel (not normalized)
     266    for (int i = -size, j = 0; i <= size; i++, j++) {
     267        float z = i / sigma / M_SQRT2;
     268        sum += smdata->kernel->data.F32[j] = 1.0 / (1 + kappa * z + pow(z,1.666));
     269    }
     270
     271    // renormalize kernel to integral of 1.0
     272    for (int i = 0; i < 2 * size + 1; i++) {
     273        smdata->kernel->data.F32[i] /= sum;
     274    }
     275
     276    return true;
     277}
     278
    250279pmPCMdata *pmPCMinit(pmSource *source, pmSourceFitOptions *fitOptions, pmModel *model, psImageMaskType maskVal, float psfSize) {
    251280
     
    312341    pcm->nsigma = 2.0;
    313342
    314     pcm->smdata = psImageSmooth_PreAlloc_DataAlloc (source->pixels, pcm->sigma, pcm->nsigma);
     343    // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector
     344    pcm->smdata = psImageSmoothCacheAlloc (source->pixels, pcm->sigma, pcm->nsigma);
     345
     346    float v1sigma = 0.5 * (axes.major + axes.minor);
     347    psImageSmoothCacheKernel_Gauss (pcm->smdata, v1sigma, PAR[PM_PAR_7]);
     348
    315349# else
    316350    // make sure we save a cached copy of the psf flux
     
    396430        psFree(pcm->smdata);
    397431        pcm->smdata = psImageSmooth_PreAlloc_DataAlloc (source->pixels, pcm->sigma, pcm->nsigma);
     432
     433    // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector
     434    pcm->smdata = psImageSmoothCacheAlloc (source->pixels, pcm->sigma, pcm->nsigma);
     435
     436    float v1sigma = 0.5 * (axes.major + axes.minor);
     437    psImageSmoothCacheKernel_Gauss (pcm->smdata, v1sigma, PAR[PM_PAR_7]);
    398438    }
    399439
     
    439479
    440480        psImageSmooth (source->modelFlux, sigma, nsigma);
     481
     482        // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector
     483        pcm->smdata = psImageSmoothCacheAlloc (source->pixels, pcm->sigma, pcm->nsigma);
     484       
     485        float v1sigma = 0.5 * (axes.major + axes.minor);
     486        psImageSmoothCacheKernel_Gauss (pcm->smdata, v1sigma, PAR[PM_PAR_7]);
     487
     488        psImageSmoothCache_F32 (source->modelFlux, pcm->smdata);
    441489    } else {
    442490        // make sure we save a cached copy of the psf flux
Note: See TracChangeset for help on using the changeset viewer.