IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 7, 2005, 2:57:14 PM (20 years ago)
Author:
Paul Price
Message:

Importing from PAP cvs tree again. This will now be the working tree.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/stacRejection.c

    r3667 r5743  
    7474    psTrace("stac.rejection", 1, "Mapping rejection masks back to source....\n");
    7575
     76    // Vectors for calculating the mean gradient
     77    psVector *grads = psVectorAlloc(nImages, PS_TYPE_F32); // Gradient for each image
     78    psVector *gradsMask = psVectorAlloc(nImages, PS_TYPE_U8); // Mask for gradient vector
     79
    7680    // Transform rejection masks back to source
    7781    psArray *inputRej = psArrayAlloc(nImages);
     
    107111        // calculate derivatives of the map, and use that as a buffer around the transformed position
    108112        // in the input image.
     113        psStats *median = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
    109114        for (int y = 0; y < nyInput; y++) {
    110115            for (int x = 0; x < nxInput; x++) {
     
    135140                                    (yPix >= 0) && (yPix <= ((psImage*)(inputs->data[j]))->numRows - 1)) {
    136141                                    // Calculate the gradient
    137                                     meanGrads += stacGradient(inputs->data[j], xPix, yPix);
     142                                    grads->data.F32[j] = stacGradient(inputs->data[j], xPix, yPix);
     143                                    gradsMask->data.U8[j] = 0;
    138144                                    numGrads++;
     145                                } else {
     146                                    gradsMask->data.U8[j] = 1; // Mask this one
    139147                                }
     148                            } else {
     149                                gradsMask->data.U8[j] = 1; // Mask this one
    140150                            }
    141151                        }
    142152                        if (numGrads > 0) {
    143                             meanGrads /= (float)numGrads;
     153                            (void)psVectorStats(median, grads, NULL, gradsMask, (psU8)1);
     154                            meanGrads = median->sampleMedian;
    144155                        } else {
    145                             meanGrads = 0;
     156                            meanGrads = 0.0;
    146157                        }
    147158
    148159#ifdef TESTING
    149                         gradient->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads;
    150 #endif
    151 
    152                         if (stacGradient(inputs->data[i], x, y) < grad * meanGrads) {
     160                        //gradient->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads;
     161                        gradient->data.F32[y][x] = meanGrads;
     162#endif
     163
     164                        //if (stacGradient(inputs->data[i], x, y) < grad * meanGrads) {
     165                        if (meanGrads > grad) {
    153166                            mask->data.U8[y][x] = 1;
    154167                            nBad++;
     
    173186            }
    174187        } // Iterating over pixels
     188        psFree(median);
    175189
    176190#ifdef CRFLUX
     
    194208        psFits *rejmapFile = psFitsAlloc(rejmapName);
    195209        psFits *gradFile = psFitsAlloc(gradName);
    196         if (!psFitsWriteImage(maskFile, NULL, mask, 0, NULL)) {
     210        if (!psFitsWriteImage(maskFile, NULL, mask, 0)) {
    197211            psErrorStackPrint(stderr, "Unable to write image: %s\n", maskName);
    198212        }
    199213        psTrace("stac", 1, "Mask image written to %s\n", maskName);
    200         if (!psFitsWriteImage(rejmapFile, NULL, rejmap, 0, NULL)) {
     214        if (!psFitsWriteImage(rejmapFile, NULL, rejmap, 0)) {
    201215            psErrorStackPrint(stderr, "Unable to write image: %s\n", rejmapName);
    202216        }
    203217        psTrace("stac", 1, "Rejection map written to %s\n", rejmapName);
    204         if (!psFitsWriteImage(gradFile, NULL, gradient, 0, NULL)) {
     218        if (!psFitsWriteImage(gradFile, NULL, gradient, 0)) {
    205219            psErrorStackPrint(stderr, "Unable to write image: %s\n", gradName);
    206220        }
     
    218232    }
    219233
     234    psFree(grads);
     235    psFree(gradsMask);
    220236
    221237    psFree(inCoords);
Note: See TracChangeset for help on using the changeset viewer.