IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 23, 2010, 1:54:27 PM (16 years ago)
Author:
Paul Price
Message:

Fixing compression, adding weighted exposure map.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_stack/psModules/src/imcombine/pmStack.c

    r27400 r27412  
    3434
    3535
    36 //#define TESTING                         // Enable test output
    37 //#define TEST_X 843-1                     // x coordinate to examine
    38 //#define TEST_Y 813-1                     // y coordinate to examine
    39 //#define TEST_RADIUS 0                    // Radius to examine
     36#define TESTING                         // Enable test output
     37#define TEST_X 843-1                     // x coordinate to examine
     38#define TEST_Y 813-1                     // y coordinate to examine
     39#define TEST_RADIUS 0                    // Radius to examine
    4040
    4141
     
    129129    float sumExp = 0.0;                 // Sum of the exposure time
    130130    float sumExpWeight = 0.0;           // Sum of the exposure time multiplied by the global weights
     131    int numGood = 0;                    // Number of good exposures
    131132    for (int i = 0; i < values->n; i++) {
    132133        sumValueWeight += values->data.F32[i] * weights->data.F32[i];
     
    138139            sumExp += exps->data.F32[i];
    139140            sumExpWeight += exps->data.F32[i] * weights->data.F32[i];
     141            numGood++;
    140142        }
    141143    }
     
    153155    }
    154156    if (expWeight) {
    155         *expWeight = sumExpWeight / sumWeight;
     157        *expWeight = sumExpWeight;
    156158    }
    157159    return true;
     
    391393                          int x, int y, // Coordinates of interest; frame of output image
    392394                          psImageMaskType bad, // Value for bad pixels
    393                           bool safe             // Safe combination?
     395                          bool safe,           // Safe combination?
     396                          float invTotalWeight    // Inverse of total weight for all inputs
    394397                          )
    395398{
     
    423426              if (exp) {
    424427                  expValue = pixelExps->data.F32[0];
     428                  expWeightValue = pixelExps->data.F32[0];
    425429              }
    426430              maskValue = 0;
     
    490494    }
    491495    if (expweight) {
    492         expweight->data.F32[y][x] = expWeightValue;
     496        expweight->data.F32[y][x] = expWeightValue * invTotalWeight;
    493497    }
    494498
     
    10241028    psVector *exps = psVectorAlloc(num, PS_TYPE_F32);    // Exposure times for each image
    10251029    psArray *stack = psArrayAlloc(num); // Stack of readouts
     1030    float totalExpWeight = 0.0;           // Total value of all weighted exposure times
     1031    float totalExp = 0.0;                 // Total exposure time
    10261032    for (int i = 0; i < num; i++) {
    10271033        pmStackData *data = input->data[i]; // Stack data for this input
     
    10331039        weights->data.F32[i] = data->weight;
    10341040        exps->data.F32[i] = data->exp;
     1041        totalExp += exps->data.F32[i];
     1042        totalExpWeight += exps->data.F32[i] * weights->data.F32[i];
    10351043        pmReadout *ro = data->readout;  // Readout of interest
    10361044        stack->data[i] = psMemIncrRefCounter(ro);
     
    10511059        }
    10521060    }
     1061    totalExpWeight = totalExp / totalExpWeight;    // Convert to inverse
    10531062
    10541063    int minInputCols, maxInputCols, minInputRows, maxInputRows; // Smallest and largest values to combine
     
    10951104    }
    10961105
    1097     psImage *exp = NULL, *expnum = NULL; // Exposure map and exposure number
     1106    psImage *exp = NULL, *expnum = NULL, *expweight = NULL; // Exposure map and exposure number
    10981107    if (expmaps) {
    10991108        if (!expmaps->image) {
     
    11061115        }
    11071116        expnum = expmaps->mask;
     1117
     1118        if (!expmaps->variance) {
     1119            expmaps->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     1120        }
     1121        expweight = expmaps->variance;
    11081122    }
    11091123
     
    11451159            combineExtract(&num, &suspect, buffer, combinedImage, combinedMask, combinedVariance,
    11461160                           input, weights, exps, addVariance, reject, x, y, maskVal, maskSuspect);
    1147             combinePixels(combinedImage, combinedMask, combinedVariance, exp, expnum, NULL,
    1148                           num, buffer, x, y, bad, safe);
     1161            combinePixels(combinedImage, combinedMask, combinedVariance, exp, expnum, expweight,
     1162                          num, buffer, x, y, bad, safe, totalExpWeight);
    11491163
    11501164            if (iter > 0) {
Note: See TracChangeset for help on using the changeset viewer.