IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7629


Ignore:
Timestamp:
Jun 21, 2006, 6:25:28 PM (20 years ago)
Author:
Paul Price
Message:

Fixing mosaicking of binned images: cell concepts (CELL.XBIN and CELL.YBIN) weren't being set for the input and output images.

Location:
trunk/ppImage/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageParseCamera.c

    r7621 r7629  
    7272    pmFPAfile *bin2 = pmFPAfileDefineFromFPA (config, byChip->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2");
    7373
    74     // set the CELL.XBIN and CELL.YBIN for the output mosaiced FPAs
    75     for (int i = 0; i < byFPA1->fpa->chips->n; i++) {
    76         pmChip *chip = byFPA1->fpa->chips->data[i];
    77         for (int j = 0; j < chip->cells->n; j++) {
    78             pmCell *cell = chip->cells->data[j];
    79             psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.XBIN", PS_META_REPLACE, "", options->xBin1);
    80             psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.YBIN", PS_META_REPLACE, "", options->yBin1);
    81         }
    82     }
    83     for (int i = 0; i < byFPA2->fpa->chips->n; i++) {
    84         pmChip *chip = byFPA2->fpa->chips->data[i];
    85         for (int j = 0; j < chip->cells->n; j++) {
    86             pmCell *cell = chip->cells->data[j];
    87             psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.XBIN", PS_META_REPLACE, "", options->xBin2);
    88             psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.YBIN", PS_META_REPLACE, "", options->yBin2);
    89         }
    90     }
    91 
    9274    // bin1 and bin2 are used as carriers: input for byFPA1, byFPA2
    9375    bin1->freeLevel = PM_FPA_LEVEL_FPA;
  • trunk/ppImage/src/ppImageRebinReadout.c

    r7621 r7629  
    1919
    2020    while ((cell = pmFPAviewNextCell (view, inFile->fpa, 1)) != NULL) {
    21         psLogMsg ("ppImageRebinChip", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    22         if (! cell->process || ! cell->file_exists) { continue; }
     21        psLogMsg ("ppImageRebinChip", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     22        if (! cell->process || ! cell->file_exists) { continue; }
    2323
    24         // process each of the readouts
    25         while ((inReadout = pmFPAviewNextReadout (view, inFile->fpa, 1)) != NULL) {
    26             if (! inReadout->data_exists) { continue; }
     24        // process each of the readouts
     25        while ((inReadout = pmFPAviewNextReadout (view, inFile->fpa, 1)) != NULL) {
     26            if (! inReadout->data_exists) { continue; }
    2727
    28             outReadout = pmFPAviewThisReadout (view, outFile->fpa);
     28            outReadout = pmFPAviewThisReadout (view, outFile->fpa);
    2929
    30             // run the rebin code
    31             ppImageRebinReadout (outReadout, inReadout, outFile);
    32         }
     30            // run the rebin code
     31            ppImageRebinReadout (outReadout, inReadout, outFile);
     32        }
     33
     34        // Get the original values for the binning
     35        bool mdok = true;               // Status of MD lookup
     36        int xBin = psMetadataLookupS32(&mdok, cell->concepts, "CELL.XBIN"); // The binning in x
     37        if (!mdok || xBin <= 0) {
     38            psLogMsg(__func__, PS_LOG_WARN, "CELL.XBIN is not set --- assuming 1.\n");
     39            xBin = 1;
     40        }
     41        int yBin = psMetadataLookupS32(&mdok, cell->concepts, "CELL.YBIN"); // The binning in y
     42        if (!mdok || yBin <= 0) {
     43            psLogMsg(__func__, PS_LOG_WARN, "CELL.YBIN is not set --- assuming 1.\n");
     44            yBin = 1;
     45        }
     46
     47        // Update the concepts with the new values for the binning
     48        pmCell *outCell = pmFPAviewThisCell(view, outFile->fpa); // The output cell
     49        psMetadataItem *binItem = psMetadataLookup(outCell->concepts, "CELL.XBIN");
     50        binItem->data.S32 = xBin * outFile->xBin;
     51        binItem = psMetadataLookup(outCell->concepts, "CELL.YBIN");
     52        binItem->data.S32 = yBin * outFile->yBin;
    3353    }
    3454    return true;
     
    5373    // do the rebinning by hand, mean only for test
    5474    for (int yOut = 0; yOut < output->image->numRows; yOut++) {
    55         for (int xOut = 0; xOut < output->image->numCols; xOut++) {
    56             value = 0;
    57             nPix = 0;
    58             for (int yIn = yOut * dY; (yIn < yOut * dY + dY) && (yIn < nY); yIn ++) {
    59                 for (int xIn = xOut * dX; (xIn < xOut * dX + dX) && (xIn < nX); xIn ++) {
    60                     value += input->image->data.F32[yIn][xIn];
    61                     nPix ++;
    62                 }
    63             }
    64             output->image->data.F32[yOut][xOut] = value / nPix;
    65         }
     75        for (int xOut = 0; xOut < output->image->numCols; xOut++) {
     76            value = 0;
     77            nPix = 0;
     78            for (int yIn = yOut * dY; (yIn < yOut * dY + dY) && (yIn < nY); yIn ++) {
     79                for (int xIn = xOut * dX; (xIn < xOut * dX + dX) && (xIn < nX); xIn ++) {
     80                    value += input->image->data.F32[yIn][xIn];
     81                    nPix ++;
     82                }
     83            }
     84            output->image->data.F32[yOut][xOut] = value / nPix;
     85        }
    6686    }
    6787
Note: See TracChangeset for help on using the changeset viewer.