Changeset 21149 for trunk/psModules/src/imcombine/pmSubtractionAnalysis.c
- Timestamp:
- Jan 22, 2009, 9:03:46 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionAnalysis.c
r20052 r21149 165 165 UPDATE_VARFACTOR(vf2, PM_SUBTRACTION_ANALYSIS_VARFACTOR_2); 166 166 167 // Kernel shape 168 { 169 psImage *image = pmSubtractionKernelImage(kernels, 0.5, 0.5, false); // Image of the kernel 170 if (!image) { 171 psError(PS_ERR_UNKNOWN, false, "Unable to generate image of kernel."); 172 return false; 173 } 174 int size = kernels->size; // Half-size of kernel 175 int fullSize = 2 * size + 1; // Full size of kernel 176 float norm = 0.0; // Normalisation (kernel sum) 177 for (int y = 0; y < fullSize; y++) { 178 for (int x = 0; x < fullSize; x++) { 179 norm += image->data.F32[y][x]; 180 } 181 } 182 float max = -INFINITY; // Maximum fraction 183 for (int r = 1; r < size; r++) { 184 unsigned long r2 = PS_SQR(r); // r^2 185 float sum = 0.0; // Sum within circle 186 for (int y = 0, v = -size; y < fullSize; y++, v++) { 187 unsigned long v2 = PS_SQR(v); // y^2 188 for (int x = 0, u = -size; x < fullSize; x++, u++) { 189 unsigned long u2 = PS_SQR(u); // u^2 190 if (u2 + v2 <= r2) { 191 sum += image->data.F32[y][x]; 192 } 193 } 194 } 195 float frac = sum / norm; // Fraction of flux moving towards centre 196 psTrace("psModules.imcombine", 5, "Deconvolution fraction at %d: %f\n", r, frac); 197 max = PS_MAX(max, frac); 198 } 199 psFree(image); 200 201 psMetadataAddF32(analysis, PS_LIST_TAIL, PM_SUBTRACTION_ANALYSIS_DECONV_MAX, 202 PS_META_DUPLICATE_OK, "Maximum deconvolution fraction", max); 203 } 204 167 205 // Kernel moments 168 206 {
Note:
See TracChangeset
for help on using the changeset viewer.
