Changeset 23937 for trunk/psModules/src/imcombine/pmSubtractionStamps.c
- Timestamp:
- Apr 20, 2009, 2:48:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r23851 r23937 232 232 233 233 234 pmSubtractionStampList *pmSubtractionStampsFind(pmSubtractionStampList *stamps, const psImage *image, 235 const psImage *subMask, const psRegion *region, 236 float threshold, int size, int footprint, float spacing, 234 pmSubtractionStampList *pmSubtractionStampsFind(pmSubtractionStampList *stamps, const psImage *image1, 235 const psImage *image2, const psImage *subMask, 236 const psRegion *region, float thresh1, float thresh2, 237 int size, int footprint, float spacing, 237 238 pmSubtractionMode mode) 238 239 { 239 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 240 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL); 240 if (!image1 && !image2) { 241 psError(PS_ERR_UNEXPECTED_NULL, true, "Must specify an image"); 242 return NULL; 243 } 244 int numCols = 0, numRows = 0; // Size of images 245 if (image1) { 246 PS_ASSERT_IMAGE_NON_NULL(image1, NULL); 247 PS_ASSERT_IMAGE_TYPE(image1, PS_TYPE_F32, NULL); 248 if (subMask) { 249 PS_ASSERT_IMAGES_SIZE_EQUAL(image1, subMask, NULL); 250 } 251 numCols = image1->numCols; 252 numRows = image1->numRows; 253 } 254 if (image2) { 255 PS_ASSERT_IMAGE_NON_NULL(image2, NULL); 256 PS_ASSERT_IMAGE_TYPE(image2, PS_TYPE_F32, NULL); 257 if (subMask) { 258 PS_ASSERT_IMAGES_SIZE_EQUAL(image2, subMask, NULL); 259 } 260 numCols = image2->numCols; 261 numRows = image2->numRows; 262 } 263 if (image1 && image2) { 264 PS_ASSERT_IMAGES_SIZE_EQUAL(image1, image2, NULL); 265 } 241 266 if (subMask) { 242 267 PS_ASSERT_IMAGE_NON_NULL(subMask, NULL); 243 PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL);244 268 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, NULL); 269 PS_ASSERT_IMAGE_SIZE(subMask, numCols, numRows, NULL); 245 270 } 246 271 PS_ASSERT_INT_POSITIVE(size, NULL); … … 254 279 return false; 255 280 } 256 if (region->x0 < 0 || region->x1 > image->numCols ||257 region->y0 < 0 || region->y1 > image->numRows) {281 if (region->x0 < 0 || region->x1 > numCols || 282 region->y0 < 0 || region->y1 > numRows) { 258 283 psString string = psRegionToString(*region); 259 284 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)", 260 string, image->numCols, image->numRows);285 string, numCols, numRows); 261 286 psFree(string); 262 287 return false; … … 264 289 } 265 290 266 int numRows = image->numRows, numCols = image->numCols; // Size of image267 291 int border = size + footprint; // Border size 268 292 … … 312 336 fluxList->n = index; 313 337 314 goodStamp = (fluxStamp > threshold) ? true : false; 338 goodStamp = true; 339 int x = xStamp + 0.5, y = yStamp + 0.5; // Pixel location 340 if (image1 && image1->data.F32[y][x] < thresh1) { 341 goodStamp = false; 342 } else if (image2 && image2->data.F32[y][x] < thresh2) { 343 goodStamp = false; 344 } 315 345 } else { 316 346 psTrace("psModules.imcombine", 9, "No sources in subregion %d", i); … … 319 349 // Use a simple method of automatically finding stamps --- take the highest pixel in the 320 350 // subregion 321 fluxStamp = threshold;351 fluxStamp = 0.0; 322 352 psRegion *subRegion = stamps->regions->data[i]; // Sub-region of interest 353 354 const psImage *image = NULL; // Image for flux of stamp 355 switch (mode) { 356 case PM_SUBTRACTION_MODE_1: 357 image = image2 ? image2 : image1; 358 break; 359 case PM_SUBTRACTION_MODE_2: 360 image = image1 ? image1 : image2; 361 break; 362 case PM_SUBTRACTION_MODE_UNSURE: 363 case PM_SUBTRACTION_MODE_DUAL: 364 // If both are available, we'll take the MIN value below in the hope of rejecting 365 // transients in both 366 image = (image1 && image2) ? NULL : (image1 ? image1 : image2); 367 default: 368 psAbort("Unrecognised mode: %x", mode); 369 } 370 323 371 for (int y = subRegion->y0; y <= subRegion->y1; y++) { 324 372 for (int x = subRegion->x0; x <= subRegion->x1; x++) { 325 if (image->data.F32[y][x] > fluxStamp && 373 if ((image1 && image1->data.F32[y][x] < thresh1) || 374 (image2 && image2->data.F32[y][x] < thresh2)) { 375 continue; 376 } 377 float value = image ? image->data.F32[y][x] : 378 PS_MIN(image1->data.F32[y][x], image2->data.F32[y][x]); // Value of image 379 if (value > fluxStamp && 326 380 checkStampMask(x, y, numCols, numRows, subMask, mode, footprint, border)) { 327 381 fluxStamp = image->data.F32[y][x];
Note:
See TracChangeset
for help on using the changeset viewer.
