- Timestamp:
- Jun 25, 2009, 2:00:56 PM (17 years ago)
- Location:
- branches/eam_branches/20090522
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090522
- Property svn:mergeinfo changed
-
branches/eam_branches/20090522/ppSub
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090522/ppSub/src/ppSubMatchPSFs.c
r24181 r24557 21 21 22 22 #include "ppSub.h" 23 24 // Normalise a region on an image 25 static void normaliseRegion(psImage *image, // Image to normalise 26 const psRegion *region, // Region of image to normalise 27 float norm // Normalisation 28 ) 29 { 30 if (!image) { 31 return; 32 } 33 psAssert(region, "Expect region"); 34 psImage *subImage = psImageSubset(image, *region); // Sub-image 35 psBinaryOp(subImage, subImage, "*", psScalarAlloc(norm, PS_TYPE_F32)); 36 psFree(subImage); 37 return; 38 } 39 23 40 24 41 bool ppSubMatchPSFs(ppSubData *data) … … 166 183 ppSubDataQuality(data, error, PPSUB_FILES_ALL); 167 184 return true; 185 } else if (error == PM_ERR_SMALL_AREA) { 186 psErrorStackPrint(stderr, "Insufficient area for PSF matching"); 187 psWarning("Insufficient area for PSF matching --- suspect bad data quality."); 188 ppSubDataQuality(data, error, PPSUB_FILES_ALL); 189 return true; 168 190 } else { 169 191 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); … … 172 194 } 173 195 196 // Need to be careful with the normalisation 197 // We will normalise everything to the normalisation of the *input* image 198 { 199 // Since the entries are MULTI, we have to retrieve them differently 200 psMetadataIterator *regIter = psMetadataIteratorAlloc(inConv->analysis, PS_LIST_HEAD, 201 "^" PM_SUBTRACTION_ANALYSIS_REGION "$"); 202 psMetadataIterator *modeIter = psMetadataIteratorAlloc(inConv->analysis, PS_LIST_HEAD, 203 "^" PM_SUBTRACTION_ANALYSIS_MODE "$"); 204 psMetadataIterator *normIter = psMetadataIteratorAlloc(inConv->analysis, PS_LIST_HEAD, 205 "^" PM_SUBTRACTION_ANALYSIS_NORM "$"); 206 psMetadataItem *regItem; // Item with region 207 while ((regItem = psMetadataGetAndIncrement(regIter))) { 208 psAssert(regItem->type == PS_DATA_REGION && regItem->data.V, "Expect region type"); 209 psRegion *region = regItem->data.V; // Region of interest 210 psMetadataItem *modeItem = psMetadataGetAndIncrement(modeIter); // Item with mode 211 psAssert(modeItem && modeItem->type == PS_TYPE_S32, "Expect subtraction mode"); 212 pmSubtractionMode mode = modeItem->data.S32; // Subtraction mode 213 psMetadataItem *normItem = psMetadataGetAndIncrement(normIter); // Item with normalisation 214 psAssert(normItem && normItem->type == PS_TYPE_F32 && isfinite(normItem->data.F32), 215 "Expect normalisation"); 216 float norm = normItem->data.F32; // Normalisation 217 218 switch (mode) { 219 case PM_SUBTRACTION_MODE_1: // Convolved the input to match template 220 case PM_SUBTRACTION_MODE_DUAL: // Convolved both; template should have flux conserved 221 psLogMsg("ppSub", PS_LOG_INFO, "Correcting image for normalisation of %f\n", norm); 222 normaliseRegion(inConv->image, region, 1.0 / norm); 223 normaliseRegion(refConv->image, region, 1.0 / norm); 224 normaliseRegion(inConv->variance, region, 1.0 / PS_SQR(norm)); 225 normaliseRegion(refConv->variance, region, 1.0 / PS_SQR(norm)); 226 break; 227 case PM_SUBTRACTION_MODE_2: // Convolved the template to match input 228 // We're already happy! 229 psLogMsg("ppSub", PS_LOG_INFO, "Image normalisation is correct\n"); 230 break; 231 default: 232 psAbort("Invalid subtraction mode: %x", mode); 233 } 234 } 235 psFree(regIter); 236 psFree(modeIter); 237 psFree(normIter); 238 } 239 240 174 241 pmConceptsCopyFPA(inConv->parent->parent->parent, inRO->parent->parent->parent, true, true); 175 242 pmConceptsCopyFPA(refConv->parent->parent->parent, refRO->parent->parent->parent, true, true);
Note:
See TracChangeset
for help on using the changeset viewer.
