Changeset 23989 for trunk/psLib
- Timestamp:
- Apr 28, 2009, 11:21:56 AM (17 years ago)
- Location:
- trunk/psLib/src/imageops
- Files:
-
- 5 edited
-
psImageGeomManip.c (modified) (3 diffs)
-
psImageMap.c (modified) (1 diff)
-
psImageMapFit.c (modified) (1 diff)
-
psImagePixelExtract.c (modified) (4 diffs)
-
psImageStats.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageGeomManip.c
r21183 r23989 110 110 out = psImageRecycle(out, outCols, outRows, in->type.type); 111 111 112 #define PS_IMAGE_REBIN_CASE(TYPE)\113 case PS_TYPE_##TYPE: {\114 ps##TYPE *outRowData; \115 ps##TYPE *vecData = vec->data.TYPE; \116 psImageMaskType *inRowMask = NULL; \117 for (psS32 row = 0; row < outRows; row++) { \118 outRowData = out->data.TYPE[row]; \119 psS32 inCurrentRow = row * scale; \120 psS32 inNextRow = (row + 1) * scale; \121 for (psS32 col = 0; col < outCols; col++) { \122 psS32 inCurrentCol = col * scale; \123 psS32 inNextCol = (col + 1) * scale; \124 psS32 n = 0; \112 #define PS_IMAGE_REBIN_CASE(TYPE) \ 113 case PS_TYPE_##TYPE: { \ 114 ps##TYPE *outRowData; \ 115 ps##TYPE *vecData = vec->data.TYPE; \ 116 psImageMaskType *inRowMask = NULL; \ 117 for (psS32 row = 0; row < outRows; row++) { \ 118 outRowData = out->data.TYPE[row]; \ 119 psS32 inCurrentRow = row * scale; \ 120 psS32 inNextRow = (row + 1) * scale; \ 121 for (psS32 col = 0; col < outCols; col++) { \ 122 psS32 inCurrentCol = col * scale; \ 123 psS32 inNextCol = (col + 1) * scale; \ 124 psS32 n = 0; \ 125 125 for (psS32 inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \ 126 ps##TYPE* inRowData = in->data.TYPE[inRow]; \127 if (mask != NULL) { \126 ps##TYPE* inRowData = in->data.TYPE[inRow]; \ 127 if (mask != NULL) { \ 128 128 inRowMask = mask->data.PS_TYPE_IMAGE_MASK_DATA[inRow]; \ 129 } \129 } \ 130 130 for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \ 131 if (maskData != NULL) { \131 if (maskData != NULL) { \ 132 132 maskData[n] = (inRowMask[inCol] & maskVal); \ 133 } \ 134 vecData[n++] = inRowData[inCol]; \ 135 } \ 136 } \ 137 vec->n = n; \ 138 if (maskVec) { \ 139 maskVec->n = n; \ 140 } \ 141 psVectorStats(myStats, vec, NULL, maskVec, 0xff); /* the mask vector has only 0 or 1 */ \ 142 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \ 143 } \ 144 } \ 145 } \ 133 } \ 134 vecData[n++] = inRowData[inCol]; \ 135 } \ 136 } \ 137 vec->n = n; \ 138 if (maskVec) { \ 139 maskVec->n = n; \ 140 } \ 141 if (!psVectorStats(myStats, vec, NULL, maskVec, 0xff)) { /* the mask vector has only 0 or 1 */ \ 142 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); \ 143 psFree(out); \ 144 out = NULL; \ 145 goto escape; \ 146 } \ 147 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \ 148 } \ 149 } \ 150 } \ 146 151 break; 147 152 … … 161 166 char* typeStr; 162 167 PS_TYPE_NAME(typeStr,in->type.type); 163 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 164 _("Specified psImage type, %s, is not supported."), 165 typeStr); 168 psError(PS_ERR_BAD_PARAMETER_TYPE, true, _("Specified psImage type, %s, is not supported."), typeStr); 166 169 psFree(out); 167 170 out = NULL; … … 169 172 } 170 173 174 escape: 171 175 psFree(vec); 172 176 psFree(maskVec); -
trunk/psLib/src/imageops/psImageMap.c
r21183 r23989 211 211 // XXX need to supply a mask and skip the masked pixels when calculating the centroid 212 212 // this will not in general be properly weighted... 213 if (psVectorStats (map->stats, fCell, dfCell, NULL, 0)) { 213 if (!psVectorStats (map->stats, fCell, dfCell, NULL, 0)) { 214 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 215 return false; 216 } 217 218 // XXX ensure only one option is selected, or save both position and width 219 map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options); 220 221 if (isnan(map->map->data.F32[iy][ix])) { 222 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1; 223 } else { 214 224 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 0; 215 // XXX ensure only one option is selected, or save both position and width216 map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options);217 225 218 226 // calculate the mean position and save: 219 227 psStatsInit (meanStat); 220 psVectorStats (meanStat, xCell, NULL, NULL, 0); 228 if (!psVectorStats (meanStat, xCell, NULL, NULL, 0)) { 229 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 230 return false; 231 } 221 232 xCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options); 222 233 psStatsInit (meanStat); 223 psVectorStats (meanStat, yCell, NULL, NULL, 0); 234 if (!psVectorStats (meanStat, yCell, NULL, NULL, 0)) { 235 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 236 return false; 237 } 224 238 yCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options); 225 } else {226 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1;227 239 } 228 240 -
trunk/psLib/src/imageops/psImageMapFit.c
r21183 r23989 73 73 74 74 // XXX does ROBUST_MEDIAN work with weight? 75 psVectorStats(map->stats, f, NULL, mask, maskValue); 75 if (!psVectorStats(map->stats, f, NULL, mask, maskValue)) { 76 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 77 return false; 78 } 76 79 77 80 map->map->data.F32[0][0] = psStatsGetValue(map->stats, mean); -
trunk/psLib/src/imageops/psImagePixelExtract.c
r21183 r23989 419 419 } 420 420 421 #define PSIMAGE_CUT_VERTICAL(TYPE) \422 case PS_TYPE_##TYPE: {\423 psVectorMaskType* maskVecData = NULL; \424 for (psS32 c = col0; c < col1; c++) { \425 ps##TYPE *imgData = input->data.TYPE[row0] + c; \426 ps##TYPE *imgVecData = imgVec->data.TYPE; \427 if (maskVec != NULL) { \421 #define PSIMAGE_CUT_VERTICAL(TYPE) \ 422 case PS_TYPE_##TYPE: { \ 423 psVectorMaskType* maskVecData = NULL; \ 424 for (psS32 c = col0; c < col1; c++) { \ 425 ps##TYPE *imgData = input->data.TYPE[row0] + c; \ 426 ps##TYPE *imgVecData = imgVec->data.TYPE; \ 427 if (maskVec != NULL) { \ 428 428 maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; \ 429 429 maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[row0][c]; /* XXX double check this... */ \ 430 430 /** old entry: maskData = (psMaskType* )(mask->data.PS_TYPE_IMAGE_MASK_DATA[row0]) + c; */ \ 431 } \ 432 for (psS32 r = row0; r < row1; r++) { \ 433 *imgVecData = *imgData; \ 434 imgVecData ++; \ 435 imgData += inCols; \ 436 if (maskVecData != NULL) { \ 437 *maskVecData = (*maskData & maskVal); \ 438 maskVecData ++; \ 439 maskData += inCols; \ 440 } \ 441 } \ 442 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); \ 443 *outData = psStatsGetValue(myStats, statistic); \ 444 if (outPosition != NULL) { \ 445 outPosition->x = c; \ 446 outPosition->y = row0; \ 447 outPosition += delta; \ 448 } \ 449 outData += delta; \ 450 } \ 451 break; \ 431 } \ 432 for (psS32 r = row0; r < row1; r++) { \ 433 *imgVecData = *imgData; \ 434 imgVecData ++; \ 435 imgData += inCols; \ 436 if (maskVecData != NULL) { \ 437 *maskVecData = (*maskData & maskVal); \ 438 maskVecData ++; \ 439 maskData += inCols; \ 440 } \ 441 } \ 442 if (!psVectorStats(myStats, imgVec, NULL, maskVec, 0xff)) { \ 443 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); \ 444 psFree(out); \ 445 out = NULL; \ 446 break; \ 447 } \ 448 *outData = psStatsGetValue(myStats, statistic); \ 449 if (outPosition != NULL) { \ 450 outPosition->x = c; \ 451 outPosition->y = row0; \ 452 outPosition += delta; \ 453 } \ 454 outData += delta; \ 455 } \ 456 break; \ 452 457 } 453 458 … … 466 471 char* typeStr; 467 472 PS_TYPE_NAME(typeStr,type); 468 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 469 _("Specified psImage type, %s, is not supported."), 470 typeStr); 473 psError(PS_ERR_BAD_PARAMETER_TYPE, true, _("Specified psImage type, %s, is not supported."), typeStr); 471 474 psFree(out); 472 475 out = NULL; … … 534 537 } 535 538 536 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); 539 if (!psVectorStats(myStats, imgVec, NULL, maskVec, 0xff)) { 540 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 541 psFree (out); 542 out = NULL; 543 break; 544 } 537 545 *outData = psStatsGetValue(myStats, statistic); 538 546 if (outPosition != NULL) { … … 933 941 934 942 for (psS32 r = 0; r < numOut; r++) { 935 psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff); 943 if (!psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff)){ 944 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 945 psFree(out); 946 out = NULL; 947 break; 948 } 936 949 outData[r] = psStatsGetValue(myStats, statistic); 937 950 } -
trunk/psLib/src/imageops/psImageStats.c
r21183 r23989 104 104 } 105 105 106 psVectorStats(stats, junkData, NULL, junkMask, 0xff); 106 if (!psVectorStats(stats, junkData, NULL, junkMask, 0xff)) { 107 psFree(junkMask); 108 psFree(junkData); 109 return false; 110 } 107 111 108 112 psFree(junkMask);
Note:
See TracChangeset
for help on using the changeset viewer.
