Changeset 821
- Timestamp:
- Jun 1, 2004, 11:30:47 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
image/psImage.c (modified) (6 diffs)
-
mathtypes/psImage.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImage.c
r820 r821 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-01 2 0:00:08$11 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-01 21:30:47 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 389 389 { 390 390 int numClipped = 0; 391 psU32numRows;392 psU32numCols;391 unsigned int numRows; 392 unsigned int numCols; 393 393 394 394 if (input == NULL) { … … 400 400 switch (input->type.type) { 401 401 402 #define psImageClipCase(type) \402 #define psImageClipCase(type)\ 403 403 case PS_TYPE_##type: { \ 404 404 ps##type minimum = (ps##type) min; \ 405 405 ps##type maximum = (ps##type) max; \ 406 for ( psU32row = 0;row<numRows;row++) { \406 for (unsigned int row = 0;row<numRows;row++) { \ 407 407 ps##type* inputRow = input->data.type[row]; \ 408 for ( psU32col = 0; col < numCols; col++) { \408 for (unsigned int col = 0; col < numCols; col++) { \ 409 409 if (inputRow[col] < minimum) { \ 410 410 inputRow[col] = (ps##type)vmin; \ … … 441 441 { 442 442 int numClipped = 0; 443 psU32numRows;444 psU32numCols;443 unsigned int numRows; 444 unsigned int numCols; 445 445 446 446 if (input == NULL) { … … 453 453 454 454 #define psImageClipNaNCase(type) \ 455 case PS_TYPE_##type: { \ 456 for (psU32 row = 0;row<numRows;row++) { \ 457 ps##type* inputRow = input->data.type[row]; \ 458 for (psU32 col = 0; col < numCols; col++) { \ 459 if (! isfinite(inputRow[col])) { \ 460 inputRow[col] = (ps##type)value; \ 461 numClipped++; \ 462 } \ 455 case PS_TYPE_##type: \ 456 for (unsigned int row = 0;row<numRows;row++) { \ 457 ps##type* inputRow = input->data.type[row]; \ 458 for (unsigned int col = 0; col < numCols; col++) { \ 459 if (! isfinite(inputRow[col])) { \ 460 inputRow[col] = (ps##type)value; \ 461 numClipped++; \ 463 462 } \ 464 463 } \ … … 478 477 return numClipped; 479 478 } 479 480 int psImageOverlaySection(psImage* image, const psImage* overlay, int col0, 481 int row0, const char* op) 482 { 483 unsigned int imageNumRows; 484 unsigned int imageNumCols; 485 unsigned int overlayNumRows; 486 unsigned int overlayNumCols; 487 unsigned int imageRowLimit; 488 unsigned int imageColLimit; 489 psElemType type; 490 491 if (image == NULL || overlay == NULL) { 492 psError(__func__,"one of the input images was NULL."); 493 return 1; 494 } 495 496 if (op == NULL) { 497 psError(__func__,"Operation can not be NULL."); 498 return 1; 499 } 500 501 type = image->type.type; 502 503 if (type != overlay->type.type) { 504 psError(__func__,"Image and overlay datatypes must match. (%d vs %d)", 505 type,overlay->type.type); 506 return 2; 507 } 508 509 imageNumRows = image->numRows; 510 imageNumCols = image->numCols; 511 overlayNumRows = overlay->numRows; 512 overlayNumCols = overlay->numCols; 513 514 /* check row0/col0 to see if it is within the image size */ 515 if (row0 < 0 || col0 < 0 || row0 >= imageNumRows || col0 >= imageNumCols) { 516 psError(__func__, "Overlay origin of (%d,%d) is outside of the image dimensions (%d x %d).", 517 col0, row0, imageNumCols, imageNumRows); 518 return 3; 519 } 520 521 /* check if overlay is totally withing input image */ 522 imageRowLimit = row0+overlayNumRows; 523 imageColLimit = col0+overlayNumCols; 524 if (imageRowLimit > imageNumRows || imageColLimit > imageNumCols) { 525 psError(__func__, "Overlay image (%d,%d -> %d,%d) is partially outside" 526 " of the input image (%d x %d).", 527 col0, row0, col0+overlayNumCols-1, row0+overlayNumRows-1, 528 imageNumCols,imageNumRows); 529 return 4; 530 } 531 532 switch (type) { 533 534 #define psImageOverlayCase(DATATYPE) \ 535 case PS_TYPE_##DATATYPE: \ 536 for (unsigned int row=row0;row<imageRowLimit;row++) { \ 537 ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \ 538 ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-row0]; \ 539 for (unsigned int col=col0;col<imageColLimit;col++) { \ 540 switch (*op) { \ 541 case '+': \ 542 imageRow[col] += overlayRow[col-col0]; \ 543 break; \ 544 case '-': \ 545 imageRow[col] -= overlayRow[col-col0]; \ 546 break; \ 547 case '*': \ 548 imageRow[col] *= overlayRow[col-col0]; \ 549 break; \ 550 case '/': \ 551 imageRow[col] /= overlayRow[col-col0]; \ 552 break; \ 553 default: \ 554 psError(__func__,"Unknown operation %s",op); \ 555 return 5; \ 556 } \ 557 } \ 558 } 559 560 psImageOverlayCase(U8); 561 psImageOverlayCase(U16); 562 psImageOverlayCase(U32); 563 psImageOverlayCase(U64); 564 psImageOverlayCase(S8); 565 psImageOverlayCase(S16); 566 psImageOverlayCase(S32); 567 psImageOverlayCase(S64); 568 psImageOverlayCase(F32); 569 psImageOverlayCase(F64); 570 psImageOverlayCase(C32); 571 psImageOverlayCase(C64); 572 573 default: 574 psError(__func__,"Can not operate on type %d.",type); 575 } 576 577 return 0; 578 } -
trunk/psLib/src/mathtypes/psImage.c
r820 r821 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-01 2 0:00:08$11 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-01 21:30:47 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 389 389 { 390 390 int numClipped = 0; 391 psU32numRows;392 psU32numCols;391 unsigned int numRows; 392 unsigned int numCols; 393 393 394 394 if (input == NULL) { … … 400 400 switch (input->type.type) { 401 401 402 #define psImageClipCase(type) \402 #define psImageClipCase(type)\ 403 403 case PS_TYPE_##type: { \ 404 404 ps##type minimum = (ps##type) min; \ 405 405 ps##type maximum = (ps##type) max; \ 406 for ( psU32row = 0;row<numRows;row++) { \406 for (unsigned int row = 0;row<numRows;row++) { \ 407 407 ps##type* inputRow = input->data.type[row]; \ 408 for ( psU32col = 0; col < numCols; col++) { \408 for (unsigned int col = 0; col < numCols; col++) { \ 409 409 if (inputRow[col] < minimum) { \ 410 410 inputRow[col] = (ps##type)vmin; \ … … 441 441 { 442 442 int numClipped = 0; 443 psU32numRows;444 psU32numCols;443 unsigned int numRows; 444 unsigned int numCols; 445 445 446 446 if (input == NULL) { … … 453 453 454 454 #define psImageClipNaNCase(type) \ 455 case PS_TYPE_##type: { \ 456 for (psU32 row = 0;row<numRows;row++) { \ 457 ps##type* inputRow = input->data.type[row]; \ 458 for (psU32 col = 0; col < numCols; col++) { \ 459 if (! isfinite(inputRow[col])) { \ 460 inputRow[col] = (ps##type)value; \ 461 numClipped++; \ 462 } \ 455 case PS_TYPE_##type: \ 456 for (unsigned int row = 0;row<numRows;row++) { \ 457 ps##type* inputRow = input->data.type[row]; \ 458 for (unsigned int col = 0; col < numCols; col++) { \ 459 if (! isfinite(inputRow[col])) { \ 460 inputRow[col] = (ps##type)value; \ 461 numClipped++; \ 463 462 } \ 464 463 } \ … … 478 477 return numClipped; 479 478 } 479 480 int psImageOverlaySection(psImage* image, const psImage* overlay, int col0, 481 int row0, const char* op) 482 { 483 unsigned int imageNumRows; 484 unsigned int imageNumCols; 485 unsigned int overlayNumRows; 486 unsigned int overlayNumCols; 487 unsigned int imageRowLimit; 488 unsigned int imageColLimit; 489 psElemType type; 490 491 if (image == NULL || overlay == NULL) { 492 psError(__func__,"one of the input images was NULL."); 493 return 1; 494 } 495 496 if (op == NULL) { 497 psError(__func__,"Operation can not be NULL."); 498 return 1; 499 } 500 501 type = image->type.type; 502 503 if (type != overlay->type.type) { 504 psError(__func__,"Image and overlay datatypes must match. (%d vs %d)", 505 type,overlay->type.type); 506 return 2; 507 } 508 509 imageNumRows = image->numRows; 510 imageNumCols = image->numCols; 511 overlayNumRows = overlay->numRows; 512 overlayNumCols = overlay->numCols; 513 514 /* check row0/col0 to see if it is within the image size */ 515 if (row0 < 0 || col0 < 0 || row0 >= imageNumRows || col0 >= imageNumCols) { 516 psError(__func__, "Overlay origin of (%d,%d) is outside of the image dimensions (%d x %d).", 517 col0, row0, imageNumCols, imageNumRows); 518 return 3; 519 } 520 521 /* check if overlay is totally withing input image */ 522 imageRowLimit = row0+overlayNumRows; 523 imageColLimit = col0+overlayNumCols; 524 if (imageRowLimit > imageNumRows || imageColLimit > imageNumCols) { 525 psError(__func__, "Overlay image (%d,%d -> %d,%d) is partially outside" 526 " of the input image (%d x %d).", 527 col0, row0, col0+overlayNumCols-1, row0+overlayNumRows-1, 528 imageNumCols,imageNumRows); 529 return 4; 530 } 531 532 switch (type) { 533 534 #define psImageOverlayCase(DATATYPE) \ 535 case PS_TYPE_##DATATYPE: \ 536 for (unsigned int row=row0;row<imageRowLimit;row++) { \ 537 ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \ 538 ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-row0]; \ 539 for (unsigned int col=col0;col<imageColLimit;col++) { \ 540 switch (*op) { \ 541 case '+': \ 542 imageRow[col] += overlayRow[col-col0]; \ 543 break; \ 544 case '-': \ 545 imageRow[col] -= overlayRow[col-col0]; \ 546 break; \ 547 case '*': \ 548 imageRow[col] *= overlayRow[col-col0]; \ 549 break; \ 550 case '/': \ 551 imageRow[col] /= overlayRow[col-col0]; \ 552 break; \ 553 default: \ 554 psError(__func__,"Unknown operation %s",op); \ 555 return 5; \ 556 } \ 557 } \ 558 } 559 560 psImageOverlayCase(U8); 561 psImageOverlayCase(U16); 562 psImageOverlayCase(U32); 563 psImageOverlayCase(U64); 564 psImageOverlayCase(S8); 565 psImageOverlayCase(S16); 566 psImageOverlayCase(S32); 567 psImageOverlayCase(S64); 568 psImageOverlayCase(F32); 569 psImageOverlayCase(F64); 570 psImageOverlayCase(C32); 571 psImageOverlayCase(C64); 572 573 default: 574 psError(__func__,"Can not operate on type %d.",type); 575 } 576 577 return 0; 578 }
Note:
See TracChangeset
for help on using the changeset viewer.
