Changeset 3813 for trunk/pois/src
- Timestamp:
- Apr 29, 2005, 10:53:49 AM (21 years ago)
- Location:
- trunk/pois/src
- Files:
-
- 4 edited
-
pois.c (modified) (2 diffs)
-
pois.h (modified) (1 diff)
-
poisFindStamps.c (modified) (2 diffs)
-
poisRejectStamps.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pois/src/pois.c
r3797 r3813 114 114 115 115 // Iterate for a good solution 116 bool badStamps = true; // Do we have bad stamps, such that we need to continue to iterate?116 psList *badStamps = NULL; // Do we have bad stamps, such that we need to continue to iterate? 117 117 for (int iterNum = 0; iterNum < config->numIter && badStamps; iterNum++) { 118 118 psTrace("pois", 1, "Iteration %d...\n", iterNum); 119 119 120 psFree(badStamps); // left over from last iteration 121 120 122 // Find stamps 121 123 stamps = poisFindStamps(stamps, refImage, mask, config); … … 175 177 // If there was rejection on the last round, re-solve the equation using only the good stamps 176 178 if (badStamps) { 179 psFree(badStamps); 177 180 solution = poisSolveEquation(solution, stamps, config); 178 181 } -
trunk/pois/src/pois.h
r3807 r3813 173 173 174 174 // Reject stamps, based on the deviations 175 boolpoisRejectStamps(psArray *stamps, // Array of stamps176 psImage *mask, // Mask image177 const psVector *deviations, // Vector of deviations for the stamps178 const poisConfig *config // Configuration175 psList *restrict poisRejectStamps(psArray *stamps, // Array of stamps 176 psImage *mask, // Mask image 177 const psVector *deviations, // Vector of deviations for the stamps 178 const poisConfig *config // Configuration 179 179 ); 180 180 -
trunk/pois/src/poisFindStamps.c
r3802 r3813 33 33 if (stamps == NULL) { 34 34 stamps = psArrayAlloc(nsx * nsy); 35 // Initialise35 // Initialise; should be done by psArrayAlloc 36 36 for (int i = 0; i < nsx * nsy; i++) { 37 stamps->data[i] = poisStampAlloc();37 stamps->data[i] = NULL; 38 38 } 39 39 } … … 44 44 for (int j = 0; j < nsy; j++) { 45 45 poisStamp *stamp = stamps->data[num]; // The stamp 46 if (stamp == NULL) { 47 stamp = stamps->data[num] = poisStampAlloc(); 48 } 46 49 47 50 // Only find a new stamp if we need to -
trunk/pois/src/poisRejectStamps.c
r3803 r3813 6 6 #define SQUARE(x) ((x)*(x)) 7 7 8 bool poisRejectStamps(psArray *stamps,// Array of stamps9 psImage *mask, // Mask image10 const psVector *deviations, // Vector of deviations for the stamps11 const poisConfig *config // Configuration8 psList *restrict poisRejectStamps(psArray *stamps, // Array of stamps 9 psImage *mask, // Mask image 10 const psVector *deviations, // Vector of deviations for the stamps 11 const poisConfig *config // Configuration 12 12 ) 13 13 { … … 21 21 assert(deviations->type.type == PS_TYPE_F32); 22 22 23 bool masked = false; // Have we masked any stamps?24 23 psVector *devMask = psVectorAlloc(stamps->n, PS_TYPE_U8); // Mask for statistics 25 24 … … 30 29 poisStamp *stamp = stamps->data[i]; // The stamp 31 30 // Only interested in the stamps that we're actually using 32 if (stamp ->status == POIS_STAMP_USED) {31 if (stamp != NULL && stamp->status == POIS_STAMP_USED) { 33 32 meanDev += SQUARE(deviations->data.F32[i]); 34 33 numDev++; … … 41 40 42 41 // Reject stamps 42 psList *rejected = NULL; // rejected stamps 43 43 for (int s = 0; s < deviations->n; s++) { 44 44 poisStamp *stamp = stamps->data[s]; 45 if (stamp == NULL) { 46 continue; 47 } 48 45 49 if (stamp->status == POIS_STAMP_USED && fabsf(deviations->data.F32[s]) > limit) { 46 masked = true;47 50 psTrace("pois.rejectStamps", 1, "Rejecting stamp %d (%d,%d): %f\n", s, stamp->x, stamp->y, 48 51 deviations->data.F32[s]); … … 56 59 57 60 // Mark stamp for replacement 58 stamp->status = POIS_STAMP_RESET; 61 stamps->data[s] = NULL; 62 63 if (rejected == NULL) { 64 rejected = psListAlloc(stamp); 65 } else { 66 bool failed = psListAdd(rejected, PS_LIST_TAIL, stamp); 67 assert(!failed); 68 } 69 psFree(stamp); 59 70 } // Bad stamps 60 71 } // Iterating over stamps … … 62 73 psFree(devMask); 63 74 64 return masked;75 return rejected; 65 76 }
Note:
See TracChangeset
for help on using the changeset viewer.
