IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2009, 5:10:19 PM (17 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/20090820
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090820

  • branches/eam_branches/20090820/magic/remove/src/streaksremove.c

    r25084 r25766  
    1212static pmConfig *parseArguments(int argc, char **argv);
    1313static bool readAndCopyToOutput(streakFiles *sf, bool exciseAll);
    14 static void exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue);
     14static void exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue);
    1515static bool warpedPixel(streakFiles *sfiles, int x, int y);
    16 static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue);
     16static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, psImageMaskType newMaskValue);
    1717static void writeImages(streakFiles *sf, bool exciseImageCube);
    1818static void updateAstrometry(streakFiles *sfiles);
    19 static void censorSources(streakFiles *sfiles, psU32 maskStreak);
     19static void censorSources(streakFiles *sfiles, psImageMaskType maskStreak);
     20static long censorPixels(streakFiles *sfiles, psImage * pixels, bool checkNonWarpedPixels, psU16 maskStreak);
    2021
    2122int
     
    146147                }
    147148
    148 
    149149                psTimerStart("REMOVE_STREAKS");
    150150
    151                 for (int y=0 ; y < sfiles->inImage->numRows; y++) {
    152                     for (int x = 0; x < sfiles->inImage->numCols; x++) {
    153                         if (psImageGet(pixels, x, y)) {
    154                             ++totalStreakPixels;
    155                             if (!checkNonWarpedPixels || warpedPixel(sfiles, x, y)) {
    156 
    157                                 excisePixel(sfiles, x, y, true, maskStreak);
    158 
    159                             } else {
    160                                 // This pixel was not included in any warp and has thus already excised
    161                                 // by exciseNonWarpedPixels
    162                             }
    163                         }
    164                     }
    165                 }
     151                totalStreakPixels += censorPixels(sfiles, pixels, checkNonWarpedPixels, maskStreak);
    166152
    167153                psLogMsg("streaksremove", PS_LOG_INFO, "time to remove streak pixels: %f\n", psTimerClear("REMOVE_STREAKS"));
     
    254240
    255241    return 0;
     242}
     243
     244static long
     245censorPixels(streakFiles *sfiles, psImage *pixels, bool checkNonWarpedPixels, psU16 maskStreak)
     246{
     247    long streakPixels = 0;
     248
     249    for (int y=0 ; y < sfiles->inImage->numRows; y++) {
     250        for (int x = 0; x < sfiles->inImage->numCols; x++) {
     251            if (psImageGet(pixels, x, y)) {
     252                ++streakPixels;
     253                if (!checkNonWarpedPixels || warpedPixel(sfiles, x, y)) {
     254
     255                    excisePixel(sfiles, x, y, true, maskStreak);
     256
     257                } else {
     258                    // This pixel was not included in any warp and has thus already excised
     259                    // by exciseNonWarpedPixels
     260                }
     261            }
     262        }
     263    }
     264    return streakPixels;
    256265}
    257266
     
    665674
    666675static void
    667 excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue)
     676excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, psImageMaskType newMaskValue)
    668677{
    669678    double exciseValue = sfiles->inImage->exciseValue;
     
    674683    }
    675684
    676     double imageValue  = psImageGet (sfiles->inImage->image,  x, y);
     685    float imageValue  = sfiles->inImage->image->data.F32[y][x];
    677686    if (sfiles->recImage && !isExciseValue(imageValue, sfiles->inImage->exciseValue) ) {
    678         psImageSet (sfiles->recImage->image,  x, y, imageValue);
     687        sfiles->recImage->image->data.F32[y][x] = imageValue;
    679688    }
    680689
    681690    if (sfiles->transparentStreaks == 0) {
    682         psImageSet (sfiles->outImage->image,  x, y, exciseValue);
     691        sfiles->outImage->image->data.F32[y][x] = exciseValue;
    683692    } else {
    684693        if (streak) {
    685694            // as a visualization aid don't mask the pixel, just change the intensity
    686             psImageSet (sfiles->outImage->image,  x, y, imageValue + sfiles->transparentStreaks);
     695            sfiles->outImage->image->data.F32[y][x] = imageValue + sfiles->transparentStreaks;
    687696        } else {
    688             psImageSet (sfiles->outImage->image,  x, y, exciseValue);
     697            sfiles->outImage->image->data.F32[y][x] = exciseValue;
    689698        }
    690699    }
     
    692701    if (sfiles->outWeight) {
    693702        if (sfiles->recWeight) {
    694             double weightValue = psImageGet (sfiles->inWeight->image, x, y);
    695             psImageSet (sfiles->recWeight->image, x, y, weightValue);
     703            sfiles->recWeight->image->data.F32[y][x] = sfiles->inWeight->image->data.F32[y][x];
    696704        }
    697705        // Assume that weight images are always a floating point type
    698         psImageSet (sfiles->outWeight->image, x, y, NAN);
     706        sfiles->outWeight->image->data.F32[y][x] = NAN;
    699707    }
    700708    if (sfiles->outMask) {
    701709        if (sfiles->recMask) {
    702             double maskValue   = psImageGet (sfiles->inMask->image,   x, y);
    703             psImageSet (sfiles->recMask->image,   x, y, maskValue);
    704         }
    705         psImageSet (sfiles->outMask->image,   x, y, newMaskValue);
     710            sfiles->recMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] =
     711                sfiles->inMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
     712        }
     713        sfiles->outMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] =
     714            sfiles->inMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] | newMaskValue;
    706715    }
    707716}
    708717
    709718static void
    710 exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue)
     719exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue)
    711720{
    712721    int cell_x0 = sfiles->astrom->cell_x0;
     
    784793// streak mask
    785794static void
    786 censorSources(streakFiles *sfiles, psU32 maskStreak)
     795censorSources(streakFiles *sfiles, psImageMaskType maskStreak)
    787796{
    788797    if ((!sfiles->inSources) || (!sfiles->outMask)) {
     
    855864            psF32 y = psMetadataLookupF32(NULL, row, "Y_PSF");
    856865
    857             psU32 mask = psImageGet(maskImage, x, y);
     866            psImageMaskType mask;
     867            if ((x >= maskImage->numCols) || (y >= maskImage->numRows) || (x <  0) || (y < 0)) {
     868                mask = maskStreak;
     869            } else {
     870                mask = maskImage->data.PS_TYPE_IMAGE_MASK_DATA[(int)y][(int)x];
     871            }
    858872
    859873            // Key the source if the center pixel is not masked with maskStreak
Note: See TracChangeset for help on using the changeset viewer.