- Timestamp:
- Oct 28, 2007, 3:40:54 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071023/psModules/src/imcombine/pmSubtraction.c
r15325 r15399 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.65 $ $Name: not supported by cvs2svn $7 * @date $Date: 2007-10- 17 02:45:40$6 * @version $Revision: 1.65.2.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-10-29 01:40:54 $ 8 8 * 9 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 907 907 for (int j = 0; j < numKernels; j++) { 908 908 psKernel *convolution = convolutions->data[j]; // Convolution of reference 909 910 // XXX Precalculate these values, so that we're not calculating the same thing for 911 // every pixel. 909 912 double polynomial = 0.0; // Value of the polynomial 910 913 for (int yOrder = 0, index = j; yOrder <= spatialOrder; yOrder++) { … … 928 931 deviations->data.F32[i] = devNorm * deviation; 929 932 psTrace("psModules.imcombine", 5, "Deviation for stamp %d (%d,%d): %f\n", 930 i, (int) stamp->x, (int)stamp->y, deviations->data.F32[i]);933 i, (int)(stamp->x + 0.5), (int)(stamp->y + 0.5), deviations->data.F32[i]); 931 934 totalSquareDev += PS_SQR(deviations->data.F32[i]); 932 935 numStamps++; … … 947 950 } 948 951 952 if (!isfinite(sigmaRej) || sigmaRej <= 0.0) { 953 psLogMsg("psModules.imcombine", PS_LOG_INFO, "RMS deviation: %f", sqrt(totalSquareDev / numStamps)); 954 psFree(deviations); 955 return 0; 956 } 957 958 int numRejected = 0; // Number of stamps rejected 959 int numGood = 0; // Number of good stamps 960 double newSquareDev = 0.0; // New square deviation 961 949 962 float limit = sigmaRej * sqrt(totalSquareDev / numStamps); // Limit on maximum deviation 950 963 psTrace("psModules.imcombine", 1, "Deviation limit: %f\n", limit); 951 964 952 int numRejected = 0;953 965 for (int i = 0; i < stamps->num; i++) { 954 966 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 955 if (stamp->status == PM_SUBTRACTION_STAMP_USED && deviations->data.F32[i] > limit) { 956 // Mask out the stamp in the image so you it's not found again 957 psTrace("psModules.imcombine", 3, "Rejecting stamp %d (%d,%d)\n", i, 958 (int)(stamp->x + 0.5), (int)(stamp->y + 0.5)); 959 numRejected++; 960 for (int y = stamp->y - footprint; y <= stamp->y + footprint; y++) { 961 for (int x = stamp->x - footprint; x <= stamp->x + footprint; x++) { 962 subMask->data.PS_TYPE_MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ; 967 if (stamp->status == PM_SUBTRACTION_STAMP_USED) { 968 if (deviations->data.F32[i] > limit) { 969 // Mask out the stamp in the image so you it's not found again 970 psTrace("psModules.imcombine", 3, "Rejecting stamp %d (%d,%d)\n", i, 971 (int)(stamp->x + 0.5), (int)(stamp->y + 0.5)); 972 numRejected++; 973 for (int y = stamp->y - footprint; y <= stamp->y + footprint; y++) { 974 for (int x = stamp->x - footprint; x <= stamp->x + footprint; x++) { 975 subMask->data.PS_TYPE_MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ; 976 } 963 977 } 964 } 965 966 // Set stamp for replacement 967 stamp->x = 0; 968 stamp->y = 0; 969 stamp->status = PM_SUBTRACTION_STAMP_REJECTED; 970 // Recalculate convolutions 971 psFree(stamp->convolutions); 972 stamp->convolutions = NULL; 973 } 974 } 978 979 // Set stamp for replacement 980 stamp->x = 0; 981 stamp->y = 0; 982 stamp->status = PM_SUBTRACTION_STAMP_REJECTED; 983 // Recalculate convolutions 984 psFree(stamp->convolutions); 985 stamp->convolutions = NULL; 986 } else { 987 numGood++; 988 newSquareDev += PS_SQR(deviations->data.F32[i]); 989 } 990 } 991 } 992 993 psLogMsg("psModules.imcombine", PS_LOG_INFO, "%d good stamps; %d rejected.\nRMS deviation: %f --> %f\n", 994 numGood, numRejected, sqrt(totalSquareDev / numStamps), sqrt(newSquareDev / numGood)); 975 995 976 996 psFree(deviations);
Note:
See TracChangeset
for help on using the changeset viewer.
