Changeset 36228
- Timestamp:
- Oct 22, 2013, 6:27:11 AM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904
- Files:
-
- 4 edited
-
psLib/src/imageops/psImageConvolve.c (modified) (4 diffs)
-
psLib/src/imageops/psImageConvolve.h (modified) (3 diffs)
-
psModules/src/objects/pmPCM_MinimizeChisq.c (modified) (1 diff)
-
psModules/src/objects/pmPCMdata.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psLib/src/imageops/psImageConvolve.c
r35767 r36228 780 780 } 781 781 782 void psImageSmooth _PreAlloc_DataFree (psImageSmooth_PreAlloc_Data *smdata) {782 void psImageSmoothCacheDataFree (psImageSmoothCacheData *smdata) { 783 783 psFree (smdata->resultX); 784 784 psFree (smdata->resultY); … … 786 786 } 787 787 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 789 psImageSmoothCacheData *psImageSmoothCacheAlloc (psImage *image, double sigma, double Nsigma) { 789 790 790 791 psImageSmooth_PreAlloc_Data *smdata = psAlloc(sizeof(psImageSmooth_PreAlloc_Data)); … … 807 808 smdata->Ny = image->numRows; // Number of rows 808 809 809 IMAGE_SMOOTH_GAUSS(smdata->kernel, smdata->Nrange, sigma, F32);810 // IMAGE_SMOOTH_GAUSS(smdata->kernel, smdata->Nrange, sigma, F32); 810 811 811 812 // use a temp running buffer for X and Y directions. … … 819 820 } 820 821 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 824 bool 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 821 830 // 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)831 bool psImageSmoothCache_F32(psImage *image, psImageSmoothCacheData *smdata) 823 832 { 824 833 PS_ASSERT_IMAGE_NON_NULL(image, false); 834 PS_ASSERT_KERNEL_NON_NULL(smdata->kernel, false); 825 835 // assert on data type 826 836 -
branches/eam_branches/ipp-20130904/psLib/src/imageops/psImageConvolve.h
r35767 r36228 26 26 #define PS_TYPE_KERNEL_NAME "psF32" ///< the data type for kernel as a string */ 27 27 28 /// a structure to contain data related to image smoothing with a 1D gauss kernel28 /// a structure to contain data related to image smoothing with a pre-cached 1D gauss kernel 29 29 typedef struct { 30 30 int Nx; … … 34 34 psF32 *resultY; 35 35 psVector *kernel; 36 } psImageSmooth _PreAlloc_Data;36 } psImageSmoothCacheData; 37 37 38 38 /// A convolution kernel … … 306 306 ); 307 307 308 psImageSmooth _PreAlloc_Data *psImageSmooth_PreAlloc_DataAlloc (psImage *image, double sigma, double Nsigma);309 bool psImageSmooth _PreAlloc_F32(psImage *image, psImageSmooth_PreAlloc_Data *smdata);308 psImageSmoothCacheData *psImageSmoothCacheAlloc (psImage *image, double sigma, double Nsigma); 309 bool psImageSmoothCache_F32(psImage *image, psImageSmoothCacheData *smdata); 310 310 311 311 /// Control threading for image convolution functions -
branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCM_MinimizeChisq.c
r36204 r36228 581 581 582 582 float ymodel = pcm->modelConvFlux->data.F32[i][j]; 583 584 // XXXX note this point here::: 583 585 float yweight = 1.0 / source->variance->data.F32[i][j]; 584 586 float delta = ymodel - source->pixels->data.F32[i][j]; -
branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCMdata.c
r36207 r36228 248 248 } 249 249 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 252 bool 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 250 279 pmPCMdata *pmPCMinit(pmSource *source, pmSourceFitOptions *fitOptions, pmModel *model, psImageMaskType maskVal, float psfSize) { 251 280 … … 312 341 pcm->nsigma = 2.0; 313 342 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 315 349 # else 316 350 // make sure we save a cached copy of the psf flux … … 396 430 psFree(pcm->smdata); 397 431 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]); 398 438 } 399 439 … … 439 479 440 480 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); 441 489 } else { 442 490 // make sure we save a cached copy of the psf flux
Note:
See TracChangeset
for help on using the changeset viewer.
