Changeset 35768 for trunk/psModules/src/objects/pmPSFtryFitEXT.c
- Timestamp:
- Jul 3, 2013, 2:37:22 PM (13 years ago)
- Location:
- trunk/psModules
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/objects/pmPSFtryFitEXT.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130509/psModules (added) merged: 35594,35613,35628,35638-35639,35643-35648,35653,35657,35662,35750
- Property svn:mergeinfo changed
-
trunk/psModules/src/objects/pmPSFtryFitEXT.c
r35560 r35768 46 46 #include "pmSourceVisual.h" 47 47 48 bool pmPSFThreads (void) { 49 50 psThreadTask *task = NULL; 51 52 task = psThreadTaskAlloc("PSF_TRY_FIT_EXT", 6); 53 task->function = &pmPSFtryFitEXT_Threaded; 54 psThreadTaskAdd(task); 55 psFree(task); 56 57 task = psThreadTaskAlloc("PSF_TRY_FIT_PSF", 6); 58 task->function = &pmPSFtryFitPSF_Threaded; 59 psThreadTaskAdd(task); 60 psFree(task); 61 62 return true; 63 } 64 65 static int Next = 0; 66 48 67 // Fit an EXT model to all candidates PSF sources. 49 68 // Note: this is independent of the modeled 2D variations in the PSF. 50 69 bool pmPSFtryFitEXT (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal) { 51 52 bool status;53 70 54 71 psTimerStart ("psf.fit"); … … 60 77 maskVal |= markVal; 61 78 62 intNext = 0;79 Next = 0; 63 80 for (int i = 0; i < psfTry->sources->n; i++) { 64 81 65 82 pmSource *source = psfTry->sources->data[i]; 66 if (!source->moments) {67 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;68 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : no moments\n", i, source->peak->x, source->peak->y);69 continue;70 }71 if (!source->moments->nPixels) {72 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : no pixels\n", i, source->peak->x, source->peak->y);73 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;74 continue;75 }76 // If mask object does not exist, mark the source as bad.77 // We cannot proceed with it because psImageMaskPixels leaves an uncleared error code last which causes78 // psphot to exit with a fault.79 if (source->maskObj == NULL) {80 psTrace ("psModules.objects", 4, "source %d (%d,%d) : null maskObj\n", i, source->peak->x, source->peak->y);81 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;82 continue;83 }84 83 85 source->modelEXT = pmSourceModelGuess (source, options->type, maskVal, markVal); 86 if (source->modelEXT == NULL) { 87 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y); 88 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 89 continue; 90 } 84 if (!source->moments) { 85 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 86 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : no moments\n", i, source->peak->x, source->peak->y); 87 continue; 88 } 89 if (!source->moments->nPixels) { 90 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : no pixels\n", i, source->peak->x, source->peak->y); 91 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 92 continue; 93 } 94 // If mask object does not exist, mark the source as bad. 95 // We cannot proceed with it because psImageMaskPixels leaves an uncleared error code last which causes 96 // psphot to exit with a fault. 97 if (source->maskObj == NULL) { 98 psTrace ("psModules.objects", 4, "source %d (%d,%d) : null maskObj\n", i, source->peak->x, source->peak->y); 99 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 100 continue; 101 } 91 102 92 // set object mask to define valid pixels 93 // XXX 0.5 PIX: is the circle symmetric about the peak coordinate (given 0.5,0.5 center)? 94 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "OR", markVal); 103 source->modelEXT = pmSourceModelGuess (source, options->type, maskVal, markVal); 104 if (source->modelEXT == NULL) { 105 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y); 106 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 107 continue; 108 } 95 109 96 // fit model as EXT, not PSF 97 status = pmSourceFitModel (source, source->modelEXT, options->fitOptions, maskVal); 110 // do some actual work on this source 111 psThreadJob *job = psThreadJobAlloc ("PSF_TRY_FIT_EXT"); 112 psArrayAdd(job->args, 1, source); 113 psArrayAdd(job->args, 1, psfTry); 114 psArrayAdd(job->args, 1, options); 115 116 PS_ARRAY_ADD_SCALAR(job->args, i, PS_TYPE_S32); 98 117 99 // clear object mask to define valid pixels 100 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 118 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 119 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 101 120 102 // exclude the poor fits 103 if (!status) { 104 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y); 105 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 106 continue; 107 } 108 Next ++; 121 # if (1) 122 if (!psThreadJobAddPending(job)) { 123 psError(PS_ERR_UNKNOWN, false, "Unable to create psf model."); 124 return false; 125 } 126 # else 127 if (!pmPSFtryFitEXT_Threaded(job)) { 128 psError(PS_ERR_UNKNOWN, false, "Unable to create psf model."); 129 return false; 130 } 131 psFree(job); 132 # endif 109 133 } 134 135 // wait for the threads to finish and manage results 136 if (!psThreadPoolWait (false, true)) { 137 psError(PS_ERR_UNKNOWN, false, "failure to model psf"); 138 return false; 139 } 140 141 // we have only supplied one type of job, so we can assume the types here 142 psThreadJob *job = NULL; 143 while ((job = psThreadJobGetDone()) != NULL) { 144 // we have no returned data from this operation 145 if (job->args->n < 1) fprintf (stderr, "error with job\n"); 146 psFree(job); 147 } 148 110 149 psLogMsg ("psphot.psftry", PS_LOG_MINUTIA, "fit ext: %f sec for %d of %ld sources\n", psTimerMark ("psf.fit"), Next, psfTry->sources->n); 111 150 psTrace ("psModules.object", 3, "keeping %d of %ld PSF candidates (EXT)\n", Next, psfTry->sources->n); … … 118 157 return true; 119 158 } 159 160 bool pmPSFtryFitEXT_Threaded (psThreadJob *job) { 161 162 pmSource *source = job->args->data[0]; 163 pmPSFtry *psfTry = job->args->data[1]; 164 pmPSFOptions *options = job->args->data[2]; 165 166 int i = PS_SCALAR_VALUE(job->args->data[3], S32); 167 168 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 169 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA); 170 171 // set object mask to define valid pixels 172 // XXX 0.5 PIX: is the circle symmetric about the peak coordinate (given 0.5,0.5 center)? 173 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "OR", markVal); 174 175 // fit model as EXT, not PSF 176 bool status = pmSourceFitModel (source, source->modelEXT, options->fitOptions, maskVal); 177 178 // clear object mask to define valid pixels 179 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 180 181 // exclude the poor fits 182 if (!status) { 183 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y); 184 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 185 return true; 186 } 187 Next ++; 188 189 return true; 190 }
Note:
See TracChangeset
for help on using the changeset viewer.
