IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25209


Ignore:
Timestamp:
Aug 26, 2009, 2:38:40 PM (17 years ago)
Author:
Paul Price
Message:

Magic bit was clobbering all other mask bits. Removed use of psImageSet and psImageGet after ensuring input is of the correct type. Turned off fuzzing when quantising, since it's already been done, and we're just propagating the values.

Location:
trunk/magic/remove/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src/streaksio.c

    r25082 r25209  
    654654            streaksExit("", PS_EXIT_DATA_ERROR);
    655655        }
     656
     657        // Ensure input is of the expected type
     658        psDataType expected = isMask ? PS_TYPE_IMAGE_MASK : PS_TYPE_F32; // Expected type for image
     659        for (int i = 0; i < in->imagecube->n; i++) {
     660            psImage *image = in->imagecube->data[i]; // Image of interest
     661            if (image->type.type != expected) {
     662                psImage *temp = psImageCopy(NULL, image, expected);
     663                psFree(image);
     664                in->imagecube->data[i] = temp;
     665            }
     666        }
    656667    }
    657668    setDataExtent(stage, in, (stage == IPP_STAGE_RAW) && !isMask);
     
    670681    sfile->fits->options = psFitsOptionsAlloc();
    671682    sfile->fits->options->scaling = PS_FITS_SCALE_MANUAL;
     683    sfile->fits->options->fuzz = false;
    672684    sfile->fits->options->bitpix = bitpix;
    673685    sfile->fits->options->bscale = bscale;
     
    11141126                // these gets are not necessary, we could just set the pixels to nan
    11151127                // but I want to get the counts
    1116                 double imageVal  = psImageGet(image, x, y);
     1128                double imageVal  = image->data.F32[y][x];
    11171129                psU32 maskVal;
    11181130                if (sfiles->stage == IPP_STAGE_RAW) {
    11191131                    unsigned int xChip, yChip;
    11201132                    cellToChipInt(&xChip, &yChip, sfiles->astrom, x, y);
    1121                     maskVal = psImageGet(mask, xChip, yChip);
     1133                    maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip];
    11221134                } else {
    1123                     maskVal = psImageGet(mask, x, y);
     1135                    maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
    11241136                }
    11251137                if (maskVal & maskMask) {
     
    11271139                    if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) {
    11281140                        ++nandPixels;
    1129                         psImageSet(image, x, y, exciseValue);
     1141                        image->data.F32[y][x] = exciseValue;
    11301142                    }
    11311143                    if (weight) {
    1132                         double weightVal = weight ? psImageGet(weight, x, y) : 0;
     1144                        double weightVal = weight ? weight->data.F32[y][x] : 0;
    11331145                        if (!isnan(weightVal)) {
    11341146                            ++nandWeights;
    1135                             psImageSet(weight, x, y, NAN);
     1147                            weight->data.F32[y][x] = NAN;
    11361148                        }
    11371149                    }
  • trunk/magic/remove/src/streaksremove.c

    r25198 r25209  
    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);
    2020static long censorPixels(streakFiles *sfiles, psImage * pixels, bool checkNonWarpedPixels, psU16 maskStreak);
    2121
     
    674674
    675675static void
    676 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)
    677677{
    678678    double exciseValue = sfiles->inImage->exciseValue;
     
    683683    }
    684684
    685     double imageValue  = psImageGet (sfiles->inImage->image,  x, y);
     685    float imageValue  = sfiles->inImage->image->data.F32[y][x];
    686686    if (sfiles->recImage && !isExciseValue(imageValue, sfiles->inImage->exciseValue) ) {
    687         psImageSet (sfiles->recImage->image,  x, y, imageValue);
     687        sfiles->recImage->image->data.F32[y][x] = imageValue;
    688688    }
    689689
    690690    if (sfiles->transparentStreaks == 0) {
    691         psImageSet (sfiles->outImage->image,  x, y, exciseValue);
     691        sfiles->outImage->image->data.F32[y][x] = exciseValue;
    692692    } else {
    693693        if (streak) {
    694694            // as a visualization aid don't mask the pixel, just change the intensity
    695             psImageSet (sfiles->outImage->image,  x, y, imageValue + sfiles->transparentStreaks);
     695            sfiles->outImage->image->data.F32[y][x] = imageValue + sfiles->transparentStreaks;
    696696        } else {
    697             psImageSet (sfiles->outImage->image,  x, y, exciseValue);
     697            sfiles->outImage->image->data.F32[y][x] = exciseValue;
    698698        }
    699699    }
     
    701701    if (sfiles->outWeight) {
    702702        if (sfiles->recWeight) {
    703             double weightValue = psImageGet (sfiles->inWeight->image, x, y);
    704             psImageSet (sfiles->recWeight->image, x, y, weightValue);
     703            sfiles->recWeight->image->data.F32[y][x] = sfiles->inWeight->image->data.F32[y][x];
    705704        }
    706705        // Assume that weight images are always a floating point type
    707         psImageSet (sfiles->outWeight->image, x, y, NAN);
     706        sfiles->outWeight->image->data.F32[y][x] = NAN;
    708707    }
    709708    if (sfiles->outMask) {
    710709        if (sfiles->recMask) {
    711             double maskValue   = psImageGet (sfiles->inMask->image,   x, y);
    712             psImageSet (sfiles->recMask->image,   x, y, maskValue);
    713         }
    714         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;
    715715    }
    716716}
    717717
    718718static void
    719 exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue)
     719exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue)
    720720{
    721721    int cell_x0 = sfiles->astrom->cell_x0;
     
    793793// streak mask
    794794static void
    795 censorSources(streakFiles *sfiles, psU32 maskStreak)
     795censorSources(streakFiles *sfiles, psImageMaskType maskStreak)
    796796{
    797797    if ((!sfiles->inSources) || (!sfiles->outMask)) {
     
    864864            psF32 y = psMetadataLookupF32(NULL, row, "Y_PSF");
    865865
    866             psU32 mask = psImageGet(maskImage, x, y);
     866            psImageMaskType mask = maskImage->data.PS_TYPE_IMAGE_MASK_DATA[(int)y][(int)x];
    867867
    868868            // Key the source if the center pixel is not masked with maskStreak
Note: See TracChangeset for help on using the changeset viewer.