IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 11, 2009, 3:54:00 PM (17 years ago)
Author:
watersc1
Message:

Bringing branch up-to-date at revision 25049

Location:
branches/czw_branch/cleanup
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup

  • branches/czw_branch/cleanup/magic/remove/src/Line.c

    r24382 r25051  
    444444                if (y >= 0 && y < numRows)
    445445                {
    446                     pixel = psAlloc (sizeof(PixelPos));
    447                     pixel->x = (unsigned int) x;
    448                     pixel->y = (unsigned int) y;
    449                     psArrayAdd (pixels, 1024, pixel);
    450                     psFree (pixel);
     446                    psImageSet(pixels, x, y, 1);
    451447                }
    452448            }
     
    494490                if (x >=0 && x < numCols)
    495491                {
    496                     pixel = psAlloc (sizeof(PixelPos));
    497                     pixel->x = (unsigned int) x;
    498                     pixel->y = (unsigned int) y;
    499                     psArrayAdd (pixels, 1024, pixel);
    500                     psFree (pixel);
     492                    psImageSet(pixels, x, y, 1);
    501493                }
    502494            }
  • branches/czw_branch/cleanup/magic/remove/src/streaksextern.c

    r24382 r25051  
    3434    int i;
    3535    Line line;
    36     StreakPixels *pixels = psArrayAllocEmpty (1024);
     36    StreakPixels *pixels = psImageAlloc(numCols, numRows, PS_TYPE_U8);
     37    psImageInit(pixels, 0);
    3738    int streaksOnComponent = 0;
    3839
  • branches/czw_branch/cleanup/magic/remove/src/streaksextern.h

    r20308 r25051  
    44/** psLib includes */
    55
    6 #include "psArray.h"
     6#include "psImage.h"
    77
    88/** streakremove includes */
     
    3636/** For now, use psArray to define a list of PixelPos pointers */
    3737
    38 typedef psArray StreakPixels;
     38typedef psImage StreakPixels;
    3939
    4040/** Create a list of pixel positions from a Streaks pointer list
  • branches/czw_branch/cleanup/magic/remove/src/streaksremove.c

    r24951 r25051  
    1313static bool readAndCopyToOutput(streakFiles *sf, bool exciseAll);
    1414static void exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue);
    15 static bool warpedPixel(streakFiles *sfiles, PixelPos *cellCoord);
     15static bool warpedPixel(streakFiles *sfiles, int x, int y);
    1616static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue);
    1717static void writeImages(streakFiles *sf, bool exciseImageCube);
     
    146146                }
    147147
    148                 totalStreakPixels +=  psArrayLength(pixels);
    149148
    150149                psTimerStart("REMOVE_STREAKS");
    151150
    152                 // for each pixel covered by the streak
    153                 for (int i = 0; i < psArrayLength (pixels); ++i) {
    154                     PixelPos *pixelPos = psArrayGet (pixels, i);
    155 
    156                     // if this pixel was not part of the warp, skip because it has already been
    157                     // excised (unless we weren't asked to check)
    158                     if (!checkNonWarpedPixels || warpedPixel(sfiles, pixelPos)) {
    159 
    160                         excisePixel(sfiles, pixelPos->x, pixelPos->y, true, maskStreak);
    161 
    162                     } else {
    163                         // This pixel was not included in any warp and has thus already excised
    164                         // by exciseNonWarpedPixels
     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                        }
    165164                    }
    166165                }
     
    178177                exciseImageCube = true;
    179178            }
    180             psArrayElementsFree (pixels);
    181179            psFree(pixels);
    182180        }
     
    756754
    757755static bool
    758 warpedPixel(streakFiles *sfiles, PixelPos *cellCoord)
     756warpedPixel(streakFiles *sfiles, int x, int y)
    759757{
    760758    PixelPos chipCoord;
     
    767765    // we clip so that the streak calculation code doesn't have to
    768766    // clipping here insures that we don't touch the overscan regions
    769     if ((cellCoord->x < 0) || (cellCoord->x >= sfiles->inImage->numCols) ||
    770         (cellCoord->y < 0) || (cellCoord->y >= sfiles->inImage->numRows)) {
     767    if ((x < 0) || (x >= sfiles->inImage->numCols) ||
     768        (y < 0) || (y >= sfiles->inImage->numRows)) {
    771769        return false;
    772770    }
    773771
    774     cellToChipInt(&chipCoord.x, &chipCoord.y, sfiles->astrom, cellCoord->x, cellCoord->y);
     772    cellToChipInt(&chipCoord.x, &chipCoord.y, sfiles->astrom, x, y);
    775773
    776774    if (chipCoord.x < 0 || chipCoord.x >= sfiles->warpedPixels->numCols) {
     
    839837    }
    840838
    841     printf("Censored %d sources\n", numCensored);
    842 
    843839    // get rid of unused elements (don't know if this is necessary)
    844840    psArrayRealloc(outTable, j);
    845841
    846842    addDestreakKeyword(in->header);
    847     if (! psFitsWriteTable(out->fits, in->header, outTable, extname)) {
    848         psError(PS_ERR_IO, false, "failed to write table to %s", out->resolved_name);
    849         streaksExit("", PS_EXIT_DATA_ERROR);
     843    if (psArrayLength(outTable) > 0) {
     844        printf("Censored %d sources\n", numCensored);
     845        if (! psFitsWriteTable(out->fits, in->header, outTable, extname)) {
     846            psError(PS_ERR_IO, false, "failed to write table to %s", out->resolved_name);
     847            streaksExit("", PS_EXIT_DATA_ERROR);
     848        }
     849    } else {
     850        printf("Censored ALL %d sources\n", numCensored);
     851        if (! psFitsWriteTableEmpty(out->fits, in->header, inTable->data[0], extname)) {
     852            psError(PS_ERR_IO, false, "failed to write empty table to %s", out->resolved_name);
     853            streaksExit("", PS_EXIT_DATA_ERROR);
     854        }
    850855    }
    851856
Note: See TracChangeset for help on using the changeset viewer.