Changeset 4367 for trunk/psLib/src/imageops/psImagePixelExtract.c
- Timestamp:
- Jun 22, 2005, 5:50:29 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImagePixelExtract.c (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImagePixelExtract.c
r4206 r4367 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-06- 10 02:30:47$10 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-06-23 03:50:29 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 24 24 25 25 psVector* psImageSlice(psVector* out, 26 psVector* slicePositions,27 const psImage* restrict in ,26 psVector* coords, 27 const psImage* restrict input, 28 28 const psImage* restrict mask, 29 29 psU32 maskVal, … … 44 44 psS32 col1 = region.x1; 45 45 46 if (in == NULL || in->data.V == NULL) {46 if (input == NULL || input->data.V == NULL) { 47 47 psError(PS_ERR_BAD_PARAMETER_NULL, true, 48 48 PS_ERRORTEXT_psImage_IMAGE_NULL); … … 52 52 53 53 if (col1 < 1) { 54 col1 += in ->numCols;54 col1 += input->numCols; 55 55 } 56 56 57 57 if (row1 < 1) { 58 row1 += in ->numRows;58 row1 += input->numRows; 59 59 } 60 60 61 61 if ( col0 < 0 || 62 62 row0 < 0 || 63 col1 > in ->numCols ||64 row1 > in ->numRows ||63 col1 > input->numCols || 64 row1 > input->numRows || 65 65 col0 >= col1 || 66 66 row0 >= row1) { … … 68 68 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 69 69 col0, col1, row0, row1, 70 in ->numCols, in->numRows);71 psFree(out); 72 return NULL; 73 } 74 75 type = in ->type.type;76 inRows = in ->numRows;77 inCols = in ->numCols;70 input->numCols, input->numRows); 71 psFree(out); 72 return NULL; 73 } 74 75 type = input->type.type; 76 inRows = input->numRows; 77 inCols = input->numCols; 78 78 79 79 if (direction == PS_CUT_X_NEG || direction == PS_CUT_Y_NEG) { … … 134 134 // psStats. 135 135 out = psVectorRecycle(out, numCols, PS_TYPE_F64); 136 if ( slicePositions != NULL) {137 slicePositions = psVectorRecycle(slicePositions, numCols, PS_TYPE_U32);138 outPosition = slicePositions->data.U32;136 if (coords != NULL) { 137 coords = psVectorRecycle(coords, numCols, PS_TYPE_U32); 138 outPosition = coords->data.U32; 139 139 } 140 140 outData = out->data.F64; … … 153 153 psMaskType* maskVecData = NULL; \ 154 154 for (psS32 c=col0;c<col1;c++) { \ 155 ps##TYPE *imgData = in ->data.TYPE[row0] + c; \155 ps##TYPE *imgData = input->data.TYPE[row0] + c; \ 156 156 ps##TYPE *imgVecData = imgVec->data.TYPE; \ 157 157 if (maskVec != NULL) { \ … … 213 213 // fill in psVector to fake out the statistics functions. 214 214 imgVec = psAlloc(sizeof(psVector)); 215 imgVec->type = in ->type;215 imgVec->type = input->type; 216 216 imgVec->n = *(int*)&imgVec->nalloc = numCols; 217 217 if (mask != NULL) { … … 224 224 // psStats. 225 225 out = psVectorRecycle(out, numRows, PS_TYPE_F64); 226 if ( slicePositions != NULL) {227 slicePositions = psVectorRecycle(slicePositions, numRows, PS_TYPE_U32);228 outPosition = slicePositions->data.U32;226 if (coords != NULL) { 227 coords = psVectorRecycle(coords, numRows, PS_TYPE_U32); 228 outPosition = coords->data.U32; 229 229 } 230 230 outData = out->data.F64; … … 239 239 // point the vector struct to the 240 240 // data to calculate the stats 241 imgVec->data.U8 = (psPtr )(in ->data.U8[r] + col0 * elementSize);241 imgVec->data.U8 = (psPtr )(input->data.U8[r] + col0 * elementSize); 242 242 if (maskVec != NULL) { 243 243 maskVec->data.U8 = (psPtr )(mask->data.U8[r] + col0 * sizeof(psMaskType)); … … 271 271 psVector* cutCols, 272 272 psVector* cutRows, 273 const psImage* in ,273 const psImage* input, 274 274 const psImage* mask, 275 275 psU32 maskVal, 276 276 psRegion region, 277 psU32nSamples,277 unsigned int nSamples, 278 278 psImageInterpolateMode mode) 279 279 { 280 280 281 if (in == NULL || in->data.V == NULL) {281 if (input == NULL || input->data.V == NULL) { 282 282 psError(PS_ERR_BAD_PARAMETER_NULL, true, 283 283 PS_ERRORTEXT_psImage_IMAGE_NULL); … … 285 285 return NULL; 286 286 } 287 psS32 numCols = in ->numCols;288 psS32 numRows = in ->numRows;287 psS32 numCols = input->numCols; 288 psS32 numRows = input->numRows; 289 289 290 290 if (nSamples < 2) { … … 352 352 } 353 353 354 out = psVectorRecycle(out, nSamples, in ->type.type);354 out = psVectorRecycle(out, nSamples, input->type.type); 355 355 356 356 float dX = (endCol - startCol) / (float)(nSamples-1); … … 370 370 cutRowsData[i] = y; \ 371 371 } \ 372 outData[i] = psImagePixelInterpolate(in ,x,y,mask,maskVal,0,mode); \372 outData[i] = psImagePixelInterpolate(input,x,y,mask,maskVal,0,mode); \ 373 373 } \ 374 374 } \ … … 376 376 377 377 378 switch (in ->type.type) {378 switch (input->type.type) { 379 379 LINEAR_CUT_CASE(U8); 380 380 LINEAR_CUT_CASE(U16); … … 392 392 default: { 393 393 char* typeStr; 394 PS_TYPE_NAME(typeStr,in ->type.type);394 PS_TYPE_NAME(typeStr,input->type.type); 395 395 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 396 396 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, … … 405 405 406 406 psVector* psImageRadialCut(psVector* out, 407 const psImage* in ,407 const psImage* input, 408 408 const psImage* restrict mask, 409 409 psU32 maskVal, 410 float centerCol,411 float centerRow,410 float x, 411 float y, 412 412 const psVector* radii, 413 413 const psStats* stats) … … 417 417 /* check the parameters */ 418 418 419 if (in == NULL || in->data.V == NULL) {419 if (input == NULL || input->data.V == NULL) { 420 420 psError(PS_ERR_BAD_PARAMETER_NULL, true, 421 421 PS_ERRORTEXT_psImage_IMAGE_NULL); … … 423 423 return NULL; 424 424 } 425 psS32 numCols = in ->numCols;426 psS32 numRows = in ->numRows;425 psS32 numCols = input->numCols; 426 psS32 numRows = input->numRows; 427 427 428 428 if (mask != NULL) { … … 446 446 } 447 447 448 if ( centerCol < 0 || centerCol>= numCols ||449 centerRow < 0 || centerRow>= numRows) {448 if (x < 0 || x >= numCols || 449 y < 0 || y >= numRows) { 450 450 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 451 451 PS_ERRORTEXT_psImage_CENTER_NOT_IN_IMAGE, 452 centerCol, centerRow,452 x, y, 453 453 numCols-1, numRows-1); 454 454 psFree(out); … … 498 498 psF32* rSq = rSqVec->data.F32; 499 499 500 psS32 startRow = centerRow- rSq[numOut];501 psS32 endRow = centerRow+ rSq[numOut];502 psS32 startCol = centerCol- rSq[numOut];503 psS32 endCol = centerCol+ rSq[numOut];500 psS32 startRow = y - rSq[numOut]; 501 psS32 endRow = y + rSq[numOut]; 502 psS32 startCol = x - rSq[numOut]; 503 psS32 endCol = x + rSq[numOut]; 504 504 505 505 if (startRow < 0) { … … 531 531 // than the area of the region of interest. 532 532 buffer[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]), 533 in ->type.type);533 input->type.type); 534 534 buffer[lcv]->n = 0; 535 535 … … 546 546 float dist; 547 547 for (psS32 row=startRow; row <= endRow; row++) { 548 psF32* inRow = in ->data.F32[row];548 psF32* inRow = input->data.F32[row]; 549 549 psMaskType* maskRow = NULL; 550 550 if (mask != NULL) { … … 552 552 } 553 553 for (psS32 col=startCol; col <= endCol; col++) { 554 dX = centerCol- (float)col - 0.5f;555 dY = centerRow- (float)row - 0.5f;554 dX = x - (float)col - 0.5f; 555 dY = y - (float)row - 0.5f; 556 556 dist = dX*dX+dY*dY; 557 557 for (psS32 r = 0; r < numOut; r++) {
Note:
See TracChangeset
for help on using the changeset viewer.
