IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 16, 2011, 5:08:28 PM (15 years ago)
Author:
bills
Message:

Accept empty cmf files as we did before

File:
1 edited

Legend:

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

    r32264 r32408  
    981981        }
    982982
    983         // XXX: Handle case where numCols == 0 Can that happen?
    984         // Previously we were writing a blank extension
    985 
    986         // For speed we get intimate with the table
    987         // avoid 2 * numRows lookups of the column number by looking
    988         // it up ahead of time and verifying that the type is what we
    989         // expect.
    990         int xCol = psFitsTableGetColumnNumber(table, "X_PSF");
    991         assert(xCol >= 0 && xCol < table->numCols);
    992         assert(table->columns[xCol].type == PS_DATA_F32);
    993 
    994         int yCol = psFitsTableGetColumnNumber(table, "Y_PSF");
    995         assert(yCol >= 0 && yCol < table->numCols);
    996         assert(table->columns[yCol].type == PS_DATA_F32);
    997 
    998         // We mark censored rows in this array.
    999         bool *rowCensored = psAlloc(table->numRows * sizeof(bool));
    1000         memset(rowCensored, 0, table->numRows * sizeof(bool));
    1001983        int numCensored = 0;
    1002 
    1003         for (int i = 0 ; i < table->numRows; i++) {
     984        bool *rowCensored = NULL;
     985        if (table->numRows > 0) {
     986            // For speed we get intimate with the table
     987            // avoid 2 * numRows lookups of the column number by looking
     988            // it up ahead of time and verifying that the type is what we
     989            // expect.
     990            int xCol = psFitsTableGetColumnNumber(table, "X_PSF");
     991            assert(xCol >= 0 && xCol < table->numCols);
     992            assert(table->columns[xCol].type == PS_DATA_F32);
     993
     994            int yCol = psFitsTableGetColumnNumber(table, "Y_PSF");
     995            assert(yCol >= 0 && yCol < table->numCols);
     996            assert(table->columns[yCol].type == PS_DATA_F32);
     997
     998            // We mark censored rows in this array.
     999            rowCensored = psAlloc(table->numRows * sizeof(bool));
     1000            memset(rowCensored, 0, table->numRows * sizeof(bool));
     1001
     1002            for (int i = 0 ; i < table->numRows; i++) {
    10041003
    10051004#ifndef GO_SLOWER
    1006             psF32 x = table->columns[xCol].data.F32[i];
    1007             psF32 y = table->columns[yCol].data.F32[i];
     1005                psF32 x = table->columns[xCol].data.F32[i];
     1006                psF32 y = table->columns[yCol].data.F32[i];
    10081007#else
    1009             psF32 x = psFitsTableGetF32(NULL, table, i, "X_PSF");
    1010             psF32 y = psFitsTableGetF32(NULL, table, i, "Y_PSF");
     1008                psF32 x = psFitsTableGetF32(NULL, table, i, "X_PSF");
     1009                psF32 y = psFitsTableGetF32(NULL, table, i, "Y_PSF");
    10111010#endif
    1012             psImageMaskType mask;
    1013             if ((x >= maskImage->numCols) || (y >= maskImage->numRows) || (x <  0) || (y < 0) || isnan(x) || isnan(y)) {
    1014                 mask = maskStreak;
    1015             } else {
    1016                 mask = maskImage->data.PS_TYPE_IMAGE_MASK_DATA[(int)y][(int)x];
    1017             }
    1018 
    1019             // Key the source if the center pixel is not masked with maskStreak
    1020             if (mask & maskStreak) {
    1021                 rowCensored[i] = true;
    1022                 numCensored++;
    1023             }
    1024         }
    1025 
    1026         // remove the censored rows from the table
    1027         if (!psFitsTableCensor(table, rowCensored)) {
    1028             streaksExit("", PS_EXIT_PROG_ERROR);
    1029         }
    1030 
    1031         addDestreakKeyword(header, true);
     1011                psImageMaskType mask;
     1012                if ((x >= maskImage->numCols) || (y >= maskImage->numRows) || (x <  0) || (y < 0) || isnan(x) || isnan(y)) {
     1013                    mask = maskStreak;
     1014                } else {
     1015                    mask = maskImage->data.PS_TYPE_IMAGE_MASK_DATA[(int)y][(int)x];
     1016                }
     1017
     1018                // Key the source if the center pixel is not masked with maskStreak
     1019                if (mask & maskStreak) {
     1020                    rowCensored[i] = true;
     1021                    numCensored++;
     1022                }
     1023            }
     1024
     1025            // remove the censored rows from the table
     1026            if (!psFitsTableCensor(table, rowCensored)) {
     1027                streaksExit("", PS_EXIT_PROG_ERROR);
     1028            }
     1029
     1030            addDestreakKeyword(header, true);
     1031        }
    10321032
    10331033        if (table->numCols > 0) {
Note: See TracChangeset for help on using the changeset viewer.