IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16628


Ignore:
Timestamp:
Feb 22, 2008, 5:01:45 PM (18 years ago)
Author:
Paul Price
Message:

Removing old code that was #if-ed out.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmStack.c

    r16626 r16628  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-02-23 03:00:30 $
     10 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2008-02-23 03:01:45 $
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1313 *
     
    479479
    480480
    481 #if 0
    482 // Examine a pixel carefully to see if it should be rejected in the stack by convolving all the input images
    483 // to the same seeing, and clipping there.
    484 static bool convolveTest(psVector *reject, // Image indices to reject for this pixel (output)
    485                          psVector *inspect, // Images indices to inspect for this pixel (input)
    486                          psArray *input, // The input pmStackData
    487                          int xPix, int yPix,   // Pixel coordinates of interest
    488                          psVector *seeing, // Seeing convolution for each image
    489                          psMaskType maskVal, // Value to mask
    490                          float extent,   // Extent of convolution (Gaussian sigmas)
    491                          float threshold// Rejection threshold (standard deviations)
    492     )
    493 {
    494     assert(reject && reject->type.type == PS_TYPE_U16);
    495     assert(input);
    496     assert(seeing);
    497     assert(seeing->n == input->n);
    498 
    499     int num = input->n;                // Number of input images
    500     psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); // Statistics
    501     psVector *values = psVectorAlloc(num, PS_TYPE_F32); // Values from convolving the image
    502     psVector *valuesMask = psVectorAlloc(num, PS_TYPE_MASK); // Mask for convolution values
    503 
    504     for (int i = 0; i < num; i++) {
    505         pmStackData *data = input->data[i]; // Stacking data
    506         int radius = extent * seeing->data.F32[i]; // How much to convolve
    507         psImage *image = data->readout->image; // Image to convolve
    508         psImage *mask = data->readout->mask; // Image mask
    509 
    510         int xMin = PS_MAX(xPix - radius, 0);
    511         int xMax = PS_MIN(xPix + radius, image->numCols - 1);
    512         int yMin = PS_MAX(yPix - radius, 0);
    513         int yMax = PS_MIN(yPix + radius, image->numRows - 1);
    514 
    515         float sum = 0.0;            // Sum of pixels in convolution
    516         float sumKernel = 0.0;      // Sum of kernel
    517         for (int y = yMin; y <= yMax; y++) {
    518             int v2 = PS_SQR(y - yPix);
    519             for (int x = xMin; x <= xMax; x++) {
    520                 int u2 = PS_SQR(x - xPix);
    521                 float kernel = expf(-(u2 + v2) / seeing->data.F32[i]);
    522                 if (!(mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) {
    523                     sum += image->data.F32[y][x] * kernel;
    524                     sumKernel += kernel;
    525                 }
    526             }
    527         }
    528 
    529         if (sumKernel != 0.0) {
    530             values->data.F32[i] = sum / sumKernel;
    531             valuesMask->data.PS_TYPE_MASK_DATA[i] = 0;
    532         } else {
    533             // Everything's masked out; don't include this pixel in the analysis
    534             values->data.F32[i] = NAN;
    535             valuesMask->data.PS_TYPE_MASK_DATA[i] = MASK_BAD;
    536         }
    537     }
    538 
    539     // Mask the ones we're inspecting
    540     for (int i = 0; i < inspect->n; i++) {
    541         valuesMask->data.PS_TYPE_MASK_DATA[inspect->data.U16[i]] |= MASK_SUSPECT;
    542     }
    543 
    544     if (!psVectorStats(stats, values, NULL, valuesMask, MASK_BAD | MASK_SUSPECT)) {
    545         psFree(stats);
    546         psFree(values);
    547         psFree(valuesMask);
    548         return false;
    549     }
    550 
    551     // Inspect the pixels of interest
    552     float mean = stats->sampleMean;       // Mean value
    553     float limit = threshold * stats->sampleStdev; // Rejection threshold
    554     for (int j = 0; j < inspect->n; j++) {
    555         int index = inspect->data.U16[j]; // Index of interest
    556         if (fabsf(values->data.F32[index] - mean) > limit) {
    557             reject->data.U16[reject->n++] = index;
    558         }
    559     }
    560 
    561     psFree(stats);
    562     psFree(values);
    563     psFree(valuesMask);
    564 
    565     return true;
    566 }
    567 #endif
    568 
    569 
    570481// Generate a "pixel map".
    571482//
     
    785696}
    786697
    787 #if 0
    788 bool pmStackReject(psArray *input, psMaskType maskVal, float extent, float threshold)
    789 {
    790     bool haveWeights;                   // Do we have the sky weight maps?
    791     bool havePixels;                    // Do we have lists of pixels?
    792     int num;                            // Number of inputs
    793     int numCols, numRows;               // Size of (sky) images
    794     if (!validateInputData(&haveWeights, &havePixels, &num, &numCols, &numRows, input)) {
    795         return false;
    796     }
    797     if (!havePixels) {
    798         psError(PS_ERR_UNEXPECTED_NULL, true, "No pixels have been flagged for possible rejection.");
    799         return false;
    800     }
    801     PS_ASSERT_FLOAT_LARGER_THAN(extent, 0.0, false);
    802 
    803     // Want to concatenate the list of pixels, but also want to know where each came from
    804     psArray *pixelMap = pixelMapGenerate(input, numCols, numRows); // Map of pixels to source
    805     psPixels *pixels = NULL;            // Total list of pixels, with no duplicates
    806     for (int i = 0; i < num; i++) {
    807         pmStackData *data = input->data[i]; // Stacking data; contains the list of pixels
    808         pixels = psPixelsConcatenate(pixels, data->pixels);
    809         // Throw out the old in preparation for the new
    810         data->pixels = psPixelsRealloc(data->pixels, 0);
    811     }
    812 
    813     // Get the convolution widths
    814     psVector *seeing = psVectorAlloc(num, PS_TYPE_F32); // Seeing for each image
    815     const float fwhm2sigma = 1.0 / (2.0*sqrt((double)2.0*(log((double)2.0)))); // Conversion FWHM --> sigma
    816     float seeingMax = -INFINITY;                // Maximum FWHM
    817     for (int i = 0; i < num; i++) {
    818         pmStackData *data = input->data[i]; // Stacking data
    819         seeing->data.F32[i] = data->seeing * fwhm2sigma;
    820         if (data->seeing > seeingMax) {
    821             seeingMax = data->seeing;
    822         }
    823     }
    824     (void)psBinaryOp(seeing, seeing, "*", seeing);
    825     (void)psBinaryOp(seeing, psScalarAlloc(PS_SQR(seeingMax), PS_TYPE_F32), "-", seeing);
    826     (void)psUnaryOp(seeing, seeing, "sqrt");
    827 
    828 
    829     psVector *reject = psVectorAllocEmpty(num, PS_TYPE_U16); // Image indices to reject for a given pixel
    830 
    831     for (int i = 0; i < pixels->n; i++) {
    832         int x = pixels->data[i].x;      // x coordinate of interest
    833         int y = pixels->data[i].y;      // y coordinate of interest
    834         psVector *inspect = pixelMapQuery(pixelMap, x, y); // Inspect these images closely
    835 
    836         // Can daisy-chain multiple tests here
    837         reject->n = 0;
    838 
    839         if (!convolveTest(reject, inspect, input, x, y, seeing, maskVal, extent, threshold)) {
    840             // Some sort of error message here; NAN and mask all the pixels
    841             for (int i = 0; i < num; i++) {
    842                 pmStackData *data = input->data[i]; // Stacking data
    843                 psPixelsAdd(data->pixels, PIXEL_LIST_BUFFER, x, y);
    844             }
    845             continue;
    846         }
    847 
    848         // Add the rejected pixels to the official rejection list
    849         for (int i = 0; i < reject->n; i++) {
    850             pmStackData *data = input->data[reject->data.U16[i]]; // Stacking data
    851             psPixelsAdd(data->pixels, PIXEL_LIST_BUFFER, x, y);
    852         }
    853     }
    854     psFree(reject);
    855     psFree(seeing);
    856     psFree(pixels);
    857     psFree(pixelMap);
    858 
    859 #ifndef PS_NO_TRACE
    860     if (psTraceGetLevel("psModules.imcombine") >= 5) {
    861         for (int i = 0; i < num; i++) {
    862             pmStackData *data = input->data[i]; // Stack data for this input
    863             psTrace("psModules.imcombine", 5, "Image %d: %ld pixels rejected.\n", i, data->pixels->n);
    864         }
    865     }
    866 #endif
    867 
    868     return true;
    869 }
    870 #endif
Note: See TracChangeset for help on using the changeset viewer.