IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26871


Ignore:
Timestamp:
Feb 10, 2010, 4:13:46 PM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/eam_branches/20091201/ppbgrestore/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ppbgrestore/src/ppbgrestoreArguments.c

    r25973 r26871  
    88pmConfig *ppbgrestoreArguments(int argc, char *argv[])
    99{
     10    int argnum;
    1011    if (argc == 1) {
    1112        usage();
     
    3233        usage();
    3334    }
     35
     36    if ((argnum = psArgumentGet(argc, argv, "-savebg"))) {
     37        psArgumentRemove(argnum, &argc, argv);
     38        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "SAVE_BACKGROUND", 0, "save background innmage", true);
     39    }
     40
    3441    if (argc != 2) usage ();
    3542
  • branches/eam_branches/20091201/ppbgrestore/src/ppbgrestoreCleanup.c

    r25973 r26871  
    2222    // fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage");
    2323
    24     fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "ppbgrestore");
     24//    fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "ppbgrestore");
    2525
    2626}
  • branches/eam_branches/20091201/ppbgrestore/src/ppbgrestoreLoop.c

    r25974 r26871  
    3030        exit(PS_EXIT_PROG_ERROR);
    3131    }
     32    pmFPAfile *background= psMetadataLookupPtr(&status, config->files, "PPBGRESTORE.BACKGROUND");
     33    if (!status) {
     34        psErrorStackPrint(stderr, "Can't find output data!\n");
     35        ppbgrestoreCleanup(config, options);
     36        exit(PS_EXIT_PROG_ERROR);
     37    }
     38    bool save_background = psMetadataLookupBool(&status, config->arguments, "SAVE_BACKGROUND");
    3239
    3340    pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest
     
    9097        }
    9198        output->save = true;
     99        background->save = save_background;
    92100
    93101        psImageBinning *binning = psphotBackgroundBinning(image, config);
     
    96104            return false;
    97105        }
    98         pmReadout *background = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKGND", image->numCols, image->numRows, PS_TYPE_F32);
     106        pmReadout *backgroundRO;
     107#define USE_CELL
     108#ifdef USE_CELL
     109        pmCell *backgroundCell = pmFPAviewThisCell(&roView, background->fpa);
     110        backgroundRO = pmReadoutAlloc(backgroundCell);
     111#else
     112        backgroundRO = pmFPAviewThisReadout(&roView, background->fpa);
     113//        backgroundRO = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKGND", image->numCols, image->numRows, PS_TYPE_F32);
     114#endif
     115        backgroundRO->image = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
     116        backgroundRO->data_exists = true;
     117        backgroundRO->parent->data_exists = true;
     118        backgroundRO->parent->parent->data_exists = true;
    99119
    100120        // linear interpolation to full-scale
    101         if (!psImageUnbin (background->image, modelRO->image, binning)) {
     121        if (!psImageUnbin (backgroundRO->image, modelRO->image, binning)) {
    102122            psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for unbinning");
    103123            psFree(binning);
     
    105125        }
    106126        psFree(binning);
    107         psF32 **backData = background->image->data.F32;
     127        psF32 **backData = backgroundRO->image->data.F32;
    108128
    109         // Do the background subtraction
     129        // Undo the background subtraction
    110130        int numCols = image->numCols, numRows = image->numRows; // Size of image
    111131        long nancount = 0;
     132        long naninputs = 0;
    112133        long finitecount = 0;
    113134        for (int y = 0; y < numRows; y++) {
     
    130151                } else if (isfinite(imageval)) {
    131152                    // XXX: TODO:following ppImage we should not modify pixels that are masked.
    132                     image->data.F32[y][x] += bgvalue;
    133                 }
     153                    image->data.F32[y][x] = imageval + bgvalue;
     154                } else {
     155                    naninputs++;
     156                }
    134157            }
     158        }
     159        if (naninputs) {
     160            printf("%ld infinite pixels found in input image\n", naninputs);
    135161        }
    136162        if (nancount) {
    137163            psWarning("%ld infinite pixels found in background %ld pixels were finite\n", nancount, finitecount);
    138164        }
    139         pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
     165//        pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
    140166
    141167        // Close chip
  • branches/eam_branches/20091201/ppbgrestore/src/ppbgrestoreParseCamera.c

    r25972 r26871  
    2323    pmFPAfile *outImage = pmFPAfileDefineOutput(config, input->fpa, "PPBGRESTORE.OUTPUT");
    2424    if (!outImage) {
    25         psError(PS_ERR_IO, false, _("Unable to generate output file from PPIMAGE.OUTPUT"));
     25        psError(PS_ERR_IO, false, _("Unable to generate output file from PPBGRESTORE.OUTPUT"));
     26        psFree(options);
     27        return NULL;
     28    }
     29    // pmFPAfile *outBG = pmFPAfileDefineOutput(config, NULL, "PPBGRESTORE.BACKGROUND");
     30    pmFPAfile *outBG = pmFPAfileDefineFromFPA(config, input->fpa, 1, 1, "PPBGRESTORE.BACKGROUND");
     31    if (!outBG) {
     32        psError(PS_ERR_IO, false, _("Unable to generate bacgkround file from PPBGRESTORE.BACKGROUND"));
    2633        psFree(options);
    2734        return NULL;
Note: See TracChangeset for help on using the changeset viewer.