IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 22, 2008, 9:18:11 AM (18 years ago)
Author:
Paul Price
Message:

ppStack is now working with the incremental reads. Needed to modify a few things in pmStack*.c so that it would combine (and reject) subimages into a large image. Added weights to pmReadoutStack.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_080214/psModules/src/imcombine/pmStackReject.c

    r16476 r16600  
    2424    int numRegions = subRegions->n;        // Number of regions
    2525    int numCols = 0, numRows = 0;       // Size of original image
    26     int minCols = INT_MAX, minRows = INT_MAX; // Minimum coordinate for image --- should be 0,0
     26    int minCols = INT_MAX, minRows = INT_MAX; // Minimum coordinate for image
    2727    int size = 0;                       // Size of kernel
    2828    for (int i = 0; i < numRegions; i++) {
     
    5858        numRows = PS_MIN(valid->y1, numRows);
    5959    }
     60    psTrace("psModules.imcombine", 1, "Rejecting [%d:%d,%d:%d]\n", minCols, numCols, minRows, numRows);
    6061
    6162    psImage *mask = psPixelsToMask(NULL, in, psRegionSet(minCols, numCols - 1, minRows, numRows - 1),
     
    7879        }
    7980        pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest
    80         if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernel, true)) {
     81        if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernel, false, true)) {
    8182            psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i);
    8283            psFree(convRO);
     
    127128    // Threshold the convolved image
    128129    psPixels *bad = psPixelsAllocEmpty(PIXEL_LIST_BUFFER); // List of pixels that should be masked
    129     for (int y = 0; y < convolved->numRows; y++) {
    130         for (int x = 0; x < convolved->numCols; x++) {
     130    for (int y = size; y < convolved->numRows - size; y++) {
     131        for (int x = size; x < convolved->numCols - size; x++) {
    131132            if (convolved->data.F32[y][x] > threshold) {
    132                 bad = psPixelsAdd(bad, PIXEL_LIST_BUFFER, x, y);
     133                // Pixel coordinates in "bad" correspond to the full image
     134                bad = psPixelsAdd(bad, PIXEL_LIST_BUFFER, x + minCols, y + minRows);
    133135            }
    134136        }
     
    137139
    138140    // Now, grow the mask to include everything that touches a bad pixel in the convolution
    139     mask = psPixelsToMask(NULL, bad, psRegionSet(0, numCols - 1, 0, numRows - 1), 0xff);
    140     assert(mask->numCols == numCols && mask->numRows == numRows);
     141    int x0 = minCols, y0 = minRows;     // Offset for mask image
     142    mask = psPixelsToMask(NULL, bad, psRegionSet(x0, numCols - 1, y0, numRows - 1), 0xff);
    141143    for (int i = 0; i < bad->n; i++) {
    142         int xPix = bad->data[i].x, yPix = bad->data[i].y; // Coordinates of interest
     144        int xPix = bad->data[i].x - x0, yPix = bad->data[i].y - y0; // Coordinates in frame of mask image
    143145        // Convolution limits
    144146        int xMin = PS_MAX(xPix - size, 0);
    145         int xMax = PS_MIN(xPix + size, numCols - 1);
     147        int xMax = PS_MIN(xPix + size, mask->numCols - 1);
    146148        int yMin = PS_MAX(yPix - size, 0);
    147         int yMax = PS_MIN(yPix + size, numRows - 1);
     149        int yMax = PS_MIN(yPix + size, mask->numRows - 1);
    148150        for (int y = yMin; y <= yMax; y++) {
    149151            for (int x = xMin; x <= xMax; x++) {
     
    153155        }
    154156    }
    155 
    156157    bad = psPixelsFromMask(bad, mask, 0xff);
    157158    psFree(mask);
    158159
     160    // Convert coordinates to frame of original image
     161    for (int i = 0; i < bad->n; i++) {
     162        int x = bad->data[i].x + x0;
     163        int y = bad->data[i].y + y0;
     164        if (x < 0 || x >= numCols || y < 0 || y >= numRows) {
     165            psWarning("Bad pixel coordinate %d: %d,%d --- ignored.",
     166                      i, x, y);
     167            continue;
     168        }
     169        bad->data[i].x = x;
     170        bad->data[i].y = y;
     171    }
     172
    159173    return bad;
    160174}
Note: See TracChangeset for help on using the changeset viewer.