IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.