Changeset 21183 for trunk/psLib/src/imageops/psImagePixelExtract.c
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImagePixelExtract.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImagePixelExtract.c
r20306 r21183 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-10-22 02:10:37 $10 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:37 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 206 206 const psImage* input, 207 207 const psImage* mask, 208 ps MaskType maskVal,208 psImageMaskType maskVal, 209 209 psRegion region, 210 210 psImageCutDirection direction, … … 357 357 return NULL; 358 358 } 359 if (mask->type.type != PS_TYPE_ MASK) {359 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 360 360 char* typeStr; 361 361 PS_TYPE_NAME(typeStr,mask->type.type); 362 362 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 363 363 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 364 typeStr, PS_TYPE_ MASK_NAME);364 typeStr, PS_TYPE_IMAGE_MASK_NAME); 365 365 psFree(out); 366 366 return NULL; … … 394 394 psVector* imgVec = psVectorAlloc(numRows, type); 395 395 psVector* maskVec = NULL; 396 ps MaskType* maskData = NULL;396 psImageMaskType* maskData = NULL; 397 397 psPixelCoord* outPosition = NULL; 398 398 … … 416 416 417 417 if (mask != NULL) { 418 maskVec = psVectorAlloc(numRows, mask->type.type); 419 } 420 #define PSIMAGE_CUT_VERTICAL(TYPE) \ 418 maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); 419 } 420 421 #define PSIMAGE_CUT_VERTICAL(TYPE) \ 421 422 case PS_TYPE_##TYPE: { \ 422 ps MaskType* maskVecData = NULL; \423 for (psS32 c =col0;c<col1;c++) { \423 psVectorMaskType* maskVecData = NULL; \ 424 for (psS32 c = col0; c < col1; c++) { \ 424 425 ps##TYPE *imgData = input->data.TYPE[row0] + c; \ 425 426 ps##TYPE *imgVecData = imgVec->data.TYPE; \ 426 427 if (maskVec != NULL) { \ 427 maskVecData = maskVec->data.U8; \ 428 maskData = (psMaskType* )(mask->data.U8[row0]) + c; \ 428 maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; \ 429 maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[row0][c]; /* XXX double check this... */ \ 430 /** old entry: maskData = (psMaskType* )(mask->data.PS_TYPE_IMAGE_MASK_DATA[row0]) + c; */ \ 429 431 } \ 430 for (psS32 r=row0;r<row1;r++) { \ 431 *(imgVecData++) = *imgData; \ 432 for (psS32 r = row0; r < row1; r++) { \ 433 *imgVecData = *imgData; \ 434 imgVecData ++; \ 432 435 imgData += inCols; \ 433 436 if (maskVecData != NULL) { \ 434 *(maskVecData++) = *maskData; \ 437 *maskVecData = (*maskData & maskVal); \ 438 maskVecData ++; \ 435 439 maskData += inCols; \ 436 440 } \ 437 441 } \ 438 psVectorStats(myStats, imgVec,NULL,maskVec,maskVal); \442 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); \ 439 443 *outData = psStatsGetValue(myStats, statistic); \ 440 444 if (outPosition != NULL) { \ … … 471 475 psFree(imgVec); 472 476 psFree(maskVec); 477 473 478 } else if (direction == PS_CUT_Y_POS || direction == PS_CUT_Y_NEG) { 474 479 // Cut in Y direction 480 // XXX use this if we drop the hackish stuff below: psVector* imgVec = psVectorAlloc(numCols, type); 475 481 psVector* imgVec = NULL; 476 482 psVector* maskVec = NULL; … … 479 485 480 486 // fill in psVector to fake out the statistics functions. 487 // XXX EAM : this seems rather hackish: just use the needed psVectorAlloc (like above)? 481 488 imgVec = psAlloc(sizeof(psVector)); 482 489 imgVec->type = input->type; 483 490 P_PSVECTOR_SET_NALLOC(imgVec,numCols); 484 if (mask != NULL) { 485 maskVec = psAlloc(sizeof(psVector)); 486 maskVec->type = mask->type; 487 P_PSVECTOR_SET_NALLOC(maskVec,numCols); 488 } 491 imgVec->n = imgVec->nalloc; 492 489 493 // recycle output to make a proper sized/type output structure 490 494 // n.b. type is double as that is the type given for all stats in … … 492 496 out = psVectorRecycle(out, numRows, PS_TYPE_F64); 493 497 out->n = numRows; 494 imgVec->n = imgVec->nalloc;495 maskVec->n = maskVec->nalloc;496 498 if (coords != NULL) { 497 499 coords = psPixelsRealloc(coords, numRows); … … 507 509 } 508 510 511 if (mask != NULL) { 512 maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); 513 // XXX the old code (below) faked out the mask vector 514 // maskVec = psAlloc(sizeof(psVector)); 515 // maskVec->type = mask->type; 516 // P_PSVECTOR_SET_NALLOC(maskVec,numCols); 517 // maskVec->n = maskVec->nalloc; 518 } 519 509 520 for (psS32 r = row0; r < row1; r++) { 510 521 // point the vector struct to the 511 522 // data to calculate the stats 512 523 imgVec->data.U8 = (psPtr )(input->data.U8[r] + col0 * elementSize); 524 525 // set the vector mask pixels based on the image pixels 513 526 if (maskVec != NULL) { 514 maskVec->data.U8 = (psPtr )(mask->data.U8[r] + col0 * sizeof(psMaskType)); 515 } 516 psVectorStats(myStats, imgVec, NULL, maskVec, maskVal); 527 psVectorMaskType *maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; 528 psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[r][col0]; 529 for (psS32 c = col0; c < col1; c++) { 530 *maskVecData = (*maskData & maskVal); 531 maskVecData ++; 532 maskData ++; 533 } 534 } 535 536 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); 517 537 *outData = psStatsGetValue(myStats, statistic); 518 538 if (outPosition != NULL) { … … 544 564 const psImage* input, 545 565 const psImage* mask, 546 ps MaskType maskVal,566 psImageMaskType maskVal, 547 567 psRegion region, 548 568 unsigned int nSamples, … … 651 671 return NULL; 652 672 } 653 if (mask->type.type != PS_TYPE_ MASK) {673 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 654 674 char* typeStr; 655 675 PS_TYPE_NAME(typeStr,mask->type.type); 656 676 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 657 677 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 658 typeStr, PS_TYPE_ MASK_NAME);678 typeStr, PS_TYPE_IMAGE_MASK_NAME); 659 679 psFree(out); 660 680 return NULL; … … 739 759 const psImage* input, 740 760 const psImage* mask, 741 ps MaskType maskVal,761 psImageMaskType maskVal, 742 762 float x, 743 763 float y, … … 765 785 return NULL; 766 786 } 767 if (mask->type.type != PS_TYPE_ MASK) {787 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 768 788 char* typeStr; 769 789 PS_TYPE_NAME(typeStr,mask->type.type); 770 790 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 771 791 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 772 typeStr, PS_TYPE_ MASK_NAME);792 typeStr, PS_TYPE_IMAGE_MASK_NAME); 773 793 psFree(out); 774 794 return NULL; … … 868 888 if (mask != NULL) { 869 889 bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]), 870 PS_TYPE_ MASK);890 PS_TYPE_VECTOR_MASK); 871 891 } 872 892 } … … 877 897 for (psS32 row=startRow; row <= endRow; row++) { 878 898 psF32* inRow = input->data.F32[row]; 879 ps MaskType* maskRow = NULL;899 psImageMaskType* maskRow = NULL; 880 900 if (mask != NULL) { 881 maskRow = mask->data.PS_TYPE_ MASK_DATA[row];901 maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[row]; 882 902 } 883 903 for (psS32 col=startCol; col <= endCol; col++) { … … 899 919 900 920 if (maskRow != NULL) { 901 bufferMask[r]->data.PS_TYPE_ MASK_DATA[n] = maskRow[col];921 bufferMask[r]->data.PS_TYPE_VECTOR_MASK_DATA[n] = (maskRow[col] & maskVal); 902 922 bufferMask[r]->n = n+1; 903 923 } … … 913 933 914 934 for (psS32 r = 0; r < numOut; r++) { 915 psVectorStats(myStats, buffer[r], NULL, bufferMask[r],maskVal);935 psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff); 916 936 outData[r] = psStatsGetValue(myStats, statistic); 917 937 }
Note:
See TracChangeset
for help on using the changeset viewer.
