Changeset 20671 for trunk/magic/remove/src/streaksremove.c
- Timestamp:
- Nov 10, 2008, 4:45:16 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/magic/remove/src/streaksremove.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/magic/remove/src/streaksremove.c
r20580 r20671 23 23 psFree(sfile); 24 24 } 25 26 // TODO: get these by reading the recipe 27 #define MASK_STREAK 0x20 28 #define MASK_BAD_WARP 0x10 29 30 25 31 26 32 // getNebServer() … … 498 504 return NULL; 499 505 } 506 507 bool gotReplace = false; 508 if ((argnum = psArgumentGet(argc, argv, "-replace"))) { 509 gotReplace = true; 510 psArgumentRemove(argnum, &argc, argv); 511 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "REPLACE", 0, "replace input files", 512 true); 513 } 500 514 501 515 … … 540 554 psArgumentRemove(argnum, &argc, argv); 541 555 bool nebulousTmp = IN_NEBULOUS(argv[argnum]); 542 if ( nebulousTmp != nebulousImage) {543 psError(PS_ERR_UNKNOWN, true, "tmproot must have %snebulous path with %s image path \n",556 if (gotReplace && (nebulousTmp != nebulousImage)) { 557 psError(PS_ERR_UNKNOWN, true, "tmproot must have %snebulous path with %s image path with -replace\n", 544 558 nebulousImage ? "" : "non ", nebulousImage ? "nebulous" : "regular"); 545 559 return NULL; … … 562 576 psError(PS_ERR_UNKNOWN, true, "-recovery is required for -stage raw\n"); 563 577 return NULL; 564 }565 bool gotReplace = false;566 if ((argnum = psArgumentGet(argc, argv, "-replace"))) {567 gotReplace = true;568 psArgumentRemove(argnum, &argc, argv);569 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "REPLACE", 0, "replace input files",570 true);571 578 } 572 579 if ((argnum = psArgumentGet(argc, argv, "-remove"))) { … … 721 728 722 729 sf->inImage->image = (psImage*) psMemIncrRefCounter(readout->image); 730 sf->inImage->numCols = readout->image->numCols; 731 sf->inImage->numRows = readout->image->numRows; 723 732 } 724 733 … … 921 930 922 931 // set up the compression parameters 923 copyFitsOptions(sf->outImage, sf->recImage, sf->inImage);932 // copyFitsOptions(sf->outImage, sf->recImage, sf->inImage); 924 933 925 934 // XXX: TODO: can we derive these values from the input header? 926 935 // psFitsCompressionGet(sf->inImage->image) gives compression none 927 936 // perhaps we should just use the definition of COMP_IMG in the configuration 928 psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);937 // psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0); 929 938 psFitsSetCompression(sf->recImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0); 930 939 … … 1251 1260 double imageValue = psImageGet (sfiles->inImage->image, x, y); 1252 1261 psImageSet (sfiles->recImage->image, x, y, imageValue); 1262 1263 #define ACTUALLY_MASK_PIXEL 1264 #ifdef ACTUALLY_MASK_PIXEL 1253 1265 psImageSet (sfiles->outImage->image, x, y, NAN); 1266 #else 1267 if (newMaskValue == MASK_BAD_WARP) { 1268 psImageSet (sfiles->outImage->image, x, y, NAN); 1269 } else { 1270 // as a visualization aid don't mask the pixel, just reduce it in intensity a bit 1271 psImageSet (sfiles->outImage->image, x, y, imageValue - 50); 1272 } 1273 #endif 1254 1274 1255 1275 // TODO: … … 1333 1353 } 1334 1354 1355 bool 1356 streakEndOnComponent(streak *streak, double r_min, double r_max, double d_min, double d_max) 1357 { 1358 if ((streak->ra1 >= r_min) && (streak->ra1 <= r_max) && 1359 (streak->dec1 >= d_min) && (streak->dec1 <= d_max)) { 1360 return true; 1361 } 1362 if ((streak->ra2 >= r_min) && (streak->ra2 <= r_max) && 1363 (streak->dec2 >= d_min) && (streak->dec2 <= d_max)) { 1364 return true; 1365 } 1366 return false; 1367 } 1368 1369 1370 Streaks * 1371 restrictStreaksToComponent(streakFiles *sfiles, Streaks *streaks) 1372 { 1373 Streaks *out = psAlloc(sizeof(Streaks)); 1374 1375 strkPt ll, ur; 1376 cellToSky(&ll, sfiles->astrom, 0, 0); 1377 cellToSky(&ur, sfiles->astrom, sfiles->inImage->numCols-1, sfiles->inImage->numRows-1); 1378 1379 double r_min, r_max, d_min, d_max; 1380 if (ll.x < ur.x) { 1381 r_min = ll.x; r_max = ur.x; 1382 } else { 1383 r_min = ur.x; r_max = ll.x; 1384 } 1385 if (ll.y < ur.y) { 1386 d_min = ll.y; d_max = ur.y; 1387 } else { 1388 d_min = ur.y; d_max = ll.y; 1389 } 1390 1391 out->list = psAlloc(streaks->size * sizeof(streak)); 1392 int j=0; 1393 for (int i=0 ; i<streaks->size; i++) { 1394 if (streakEndOnComponent(&streaks->list[i], r_min, r_max, d_min, d_max)) { 1395 out->list[j++] = streaks->list[i]; 1396 } 1397 1398 } 1399 out->size = j; 1400 return out; 1401 } 1402 1335 1403 int 1336 1404 main(int argc, char *argv[]) … … 1359 1427 streakFiles *sfiles = openFiles(config); 1360 1428 1361 if (CHIP_LEVEL_INPUT(sfiles->stage)) { 1429 bool status; 1430 bool checkWarpedPixels = ! psMetadataLookupBool(&status, config->arguments, "INCLUDE_NON_WARPED"); 1431 if (checkWarpedPixels) { 1362 1432 // From ICD: 1363 1433 // In the raw and detrended images, the pixels which were not … … 1394 1464 // Identify pixels to mask because of streaks 1395 1465 1466 #ifdef notyet 1467 Streaks *componentStreaks = NULL; 1468 Streaks *streaksToProcess; 1469 1470 bool only_component_streaks = false; // XXX flesh this out and make it an option 1471 if (only_component_streaks) { 1472 componentStreaks = restrictStreaksToComponent(sfiles, streaks); 1473 streaksToProcess = componentStreaks; 1474 } else { 1475 streaksToProcess = streaks; 1476 } 1477 1478 pixels = streak_on_component (streaksToProcess, sfiles->astrom, 1479 sfiles->inImage->numCols, sfiles->inImage->numRows); 1480 if (componentStreaks) { 1481 psFree(componentStreaks); 1482 } 1483 #else 1396 1484 pixels = streak_on_component (streaks, sfiles->astrom, 1397 1485 sfiles->inImage->numCols, sfiles->inImage->numRows); 1486 #endif 1398 1487 // XXX: 1399 1488 // … … 1401 1490 // in a config somewhere? Not sure how to properly set the maskValue. 1402 1491 // WES just pick some numbers 1403 #define MASK_STREAK 42 1404 #define MASK_NOT_WARPED 51 1405 1406 exciseNonWarpedPixels(sfiles, MASK_NOT_WARPED);1492 1493 if (checkWarpedPixels) { 1494 exciseNonWarpedPixels(sfiles, MASK_BAD_WARP); 1495 } 1407 1496 1408 1497 if (sfiles->inImage->image) { … … 1410 1499 pixelPos = psArrayGet (pixels, i); 1411 1500 1412 if ( warpedPixel(sfiles, pixelPos)) {1501 if (!checkWarpedPixels || warpedPixel(sfiles, pixelPos)) { 1413 1502 1414 1503 excisePixel(sfiles, pixelPos->x, pixelPos->y, MASK_STREAK); … … 1443 1532 } 1444 1533 1445 bool status;1446 1534 if (psMetadataLookupBool(&status, config->arguments, "REPLACE")) { 1447 1535 // swap the instances for the input and output
Note:
See TracChangeset
for help on using the changeset viewer.
