Changeset 30641
- Timestamp:
- Feb 15, 2011, 3:55:42 PM (15 years ago)
- File:
-
- 1 edited
-
tags/ipp-20101215/ppImage/src/ppImageAddNoise.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20101215/ppImage/src/ppImageAddNoise.c
r30627 r30641 20 20 21 21 // grizy variances to add to turn MD exposure -> 3pi, calculated from the DRM 22 static float add_sigmas[] = {NAN, 13.39, 23.79, 75.25, 110.19, 128.84};22 // static float add_sigmas[] = {NAN, 13.39, 23.79, 75.25, 110.19, 128.84}; 23 23 24 24 // Target Exposure times for 3pi in grizy 25 25 static float expTimes3Pi[] = {NAN, 43.0, 40.0, 45.0, 30.0, 30.0}; 26 float expTime = psMetadataLookupF32(NULL, fpa->concepts, "FPA.EXPOSURE"); // Exposure time for image26 float expTime = psMetadataLookupF32(NULL, fpa->concepts, "FPA.EXPOSURE"); // Exposure time for image 27 27 28 28 // Something to choose the band, g,r,i,z,y = 0,1,2,3,4 respectively … … 60 60 61 61 // Add in appropriate variance, and scale the image 62 float expTimeScaling= expTime/expTimes3Pi[band];63 // XXX why was this not used? float expTimeScalingSqd = PS_SQR(expTimeScaling);62 float rho = expTime/expTimes3Pi[band]; 63 float rho2 = PS_SQR(rho); 64 64 65 65 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 66 66 67 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 68 stats->nSubsample = 10000; 69 70 psImageBackground(stats, NULL, inReadout->image, inReadout->mask, 0xffff, rng); 71 double MSKY_MN = stats->sampleMedian; 72 73 // set GAIN and RDNOISE to nominal values: 74 double GAIN = 1.0; // electrons / DN 75 double RDNOISE = 6.0; // electrons (== DN) 76 77 double add_sigma = sqrt((MSKY_MN/GAIN)*(rho - 1.0) + PS_SQR(RDNOISE)*(rho2 - 1.0)); 78 67 79 for (int iy = 0; iy < image->numRows; iy++){ 68 80 for (int ix = 0; ix < image->numCols; ix++){ 69 image->data.F32[iy][ix] += ppImageRandomGaussian(rng, 0.0, add_sigma s[band]);70 image->data.F32[iy][ix] /= expTimeScaling;71 variance->data.F32[iy][ix] += PS_SQR(add_sigma s[band]);72 variance->data.F32[iy][ix] /= expTimeScaling;81 image->data.F32[iy][ix] += ppImageRandomGaussian(rng, 0.0, add_sigma); 82 image->data.F32[iy][ix] /= rho; 83 variance->data.F32[iy][ix] += PS_SQR(add_sigma); 84 variance->data.F32[iy][ix] /= rho2; 73 85 } 74 86 }
Note:
See TracChangeset
for help on using the changeset viewer.
