Changeset 32410
- Timestamp:
- Sep 16, 2011, 5:11:00 PM (15 years ago)
- Location:
- tags/ipp-20110622
- Files:
-
- 2 edited
-
magic/remove/src/streaksremove.c (modified) (1 diff, 1 prop)
-
psLib/src/fits/psFitsTableNew.c (modified) (3 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20110622/magic/remove/src/streaksremove.c
- Property svn:mergeinfo set to
r32398 r32410 981 981 } 982 982 983 // XXX: Handle case where numCols == 0 Can that happen?984 // Previously we were writing a blank extension985 986 // For speed we get intimate with the table987 // avoid 2 * numRows lookups of the column number by looking988 // it up ahead of time and verifying that the type is what we989 // 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));1001 983 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++) { 1004 1003 1005 1004 #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]; 1008 1007 #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"); 1011 1010 #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 } 1032 1032 1033 1033 if (table->numCols > 0) { -
tags/ipp-20110622/psLib/src/fits/psFitsTableNew.c
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psLib/src/fits/psFitsTableNew.c merged eligible /branches/czw_branch/20101203/psLib/src/fits/psFitsTableNew.c 29907-30631 /branches/eam_branches/ipp-20101103/psLib/src/fits/psFitsTableNew.c 29657-29920 /branches/eam_branches/ipp-20101205/psLib/src/fits/psFitsTableNew.c 29959-30585 /branches/eam_branches/ipp-20110213/psLib/src/fits/psFitsTableNew.c 30628-31149 /branches/eam_branches/ipp-20110404/psLib/src/fits/psFitsTableNew.c 31166-31444 /branches/eam_branches/ipp-20110505/psLib/src/fits/psFitsTableNew.c 31458-31658
r32399 r32410 117 117 118 118 psFitsTable* psFitsTableAlloc(int numCols, int numRows) { 119 if (numCols <= 0) { 119 if (numCols < 0) { 120 // empty table 120 121 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 121 122 "Can't allocate a psFitsTable with %d columns.", numCols); … … 127 128 table->numRows = numRows; 128 129 table->numCols = numCols; 129 table->columns = psAlloc(sizeof(psFitsTableColumn) * numCols); 130 memset(table->columns, sizeof(psFitsTableColumn) * numCols, 0); 130 if (numCols > 0) { 131 table->columns = psAlloc(sizeof(psFitsTableColumn) * numCols); 132 memset(table->columns, sizeof(psFitsTableColumn) * numCols, 0); 133 } else { 134 table->columns = NULL; 135 } 131 136 psMemSetDeallocator(table, (psFreeFunc) freeTable); 132 137 … … 141 146 if (!readTableCheck(fits)) { 142 147 if (emptyTableCheck(fits)) { 143 return NULL; 148 psFitsTable *table = psFitsTableAlloc(0, 0); 149 return table; 144 150 } 145 151 psError(PS_ERR_BAD_FITS, true, "Extension is not a table"); -
Property svn:mergeinfo
set to (toggle deleted branches)
Note:
See TracChangeset
for help on using the changeset viewer.
