Changeset 5227 for trunk/psLib/src/imageops
- Timestamp:
- Oct 5, 2005, 4:41:07 PM (21 years ago)
- Location:
- trunk/psLib/src/imageops
- Files:
-
- 3 edited
-
Makefile.am (modified) (2 diffs)
-
psImagePixelManip.c (modified) (2 diffs)
-
psImagePixelManip.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/Makefile.am
r4981 r5227 10 10 psImagePixelManip.c \ 11 11 psImageStats.c \ 12 psImageStructManip.c 12 psImageStructManip.c \ 13 psImageMaskOps.c 13 14 14 15 EXTRA_DIST = imageops.i … … 21 22 psImagePixelManip.h \ 22 23 psImageStats.h \ 23 psImageStructManip.h 24 psImageStructManip.h \ 25 psImageMaskOps.h -
trunk/psLib/src/imageops/psImagePixelManip.c
r5224 r5227 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-10-0 5 03:51:43$12 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-10-06 02:41:07 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 396 396 } 397 397 398 // mask the area contained by the region399 // the region is defined wrt the parent image400 void psImageMaskRegion(psImage *image,401 psRegion region,402 const char *op,403 psMaskType maskValue)404 {405 for (int j = 0; j < image->numRows; j++) {406 for (int i = 0; i < image->numCols; i++) {407 if ( (j + image->row0) >= region.y0 &&408 (j + image->row0) <= region.y1 &&409 (i + image->col0) >= region.x0 &&410 (i + image->col0) <= region.x1 ) {411 if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {412 image->data.PS_TYPE_MASK_DATA[j][i] &= maskValue;413 } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {414 image->data.PS_TYPE_MASK_DATA[j][i] |= maskValue;415 } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {416 image->data.PS_TYPE_MASK_DATA[j][i] = maskValue;417 } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {418 image->data.PS_TYPE_MASK_DATA[j][i] ^= maskValue;419 } else {420 psError(PS_ERR_BAD_PARAMETER_VALUE,true,421 "The logical operation specified is incorrect\n");422 return;423 }424 }425 }426 }427 /*428 for (int iy = 0; iy < image->numRows; iy++) {429 for (int ix = 0; ix < image->numCols; ix++) {430 if (ix + image->col0 >= region.x0)431 continue;432 if (ix + image->col0 <= region.x1)433 continue;434 if (iy + image->row0 >= region.y0)435 continue;436 if (iy + image->row0 <= region.y1)437 continue;438 if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {439 image->data.PS_TYPE_MASK_DATA[iy][ix] &= maskValue;440 } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {441 image->data.PS_TYPE_MASK_DATA[iy][ix] |= maskValue;442 } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {443 image->data.PS_TYPE_MASK_DATA[iy][ix] = maskValue;444 } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {445 image->data.PS_TYPE_MASK_DATA[iy][ix] ^= maskValue;446 }447 }448 }449 */450 }451 452 // mask the area not contained by the region453 // the region is defined wrt the parent image454 void psImageKeepRegion(psImage *image,455 psRegion region,456 const char *op,457 psMaskType maskValue)458 {459 for (int j = 0; j < image->numRows; j++) {460 for (int i = 0; i < image->numCols; i++) {461 if ( (j + image->row0) < region.y0 ||462 (j + image->row0) > region.y1 ||463 (i + image->col0) < region.x0 ||464 (i + image->col0) > region.x1 ) {465 if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {466 image->data.PS_TYPE_MASK_DATA[j][i] &= maskValue;467 } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {468 image->data.PS_TYPE_MASK_DATA[j][i] |= maskValue;469 } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {470 image->data.PS_TYPE_MASK_DATA[j][i] = maskValue;471 } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {472 image->data.PS_TYPE_MASK_DATA[j][i] ^= maskValue;473 } else {474 psError(PS_ERR_BAD_PARAMETER_VALUE,true,475 "The logical operation specified is incorrect\n");476 return;477 }478 }479 }480 }481 /*482 for (int iy = 0; iy < image->numRows; iy++) {483 for (int ix = 0; ix < image->numCols; ix++) {484 if (ix + image->col0 < region.x0)485 goto maskit;486 if (ix + image->col0 > region.x1)487 goto maskit;488 if (iy + image->row0 < region.y0)489 goto maskit;490 if (iy + image->row0 > region.y1)491 goto maskit;492 continue;493 maskit:494 if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {495 image->data.PS_TYPE_MASK_DATA[iy][ix] &= maskValue;496 } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {497 image->data.PS_TYPE_MASK_DATA[iy][ix] |= maskValue;498 } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {499 image->data.PS_TYPE_MASK_DATA[iy][ix] = maskValue;500 } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {501 image->data.PS_TYPE_MASK_DATA[iy][ix] ^= maskValue;502 }503 }504 }505 */506 }507 508 // mask the area contained by the region509 // the region is defined wrt the parent image510 void psImageMaskCircle(psImage *image,511 double x,512 double y,513 double radius,514 const char *op,515 psMaskType maskValue)516 {517 if (image == NULL) {518 psError(PS_ERR_BAD_PARAMETER_NULL, true,519 "Invalid image input. Image is NULL.\n");520 return;521 }522 523 524 double dx, dy, r2, R2;525 526 R2 = PS_SQR(radius);527 528 for (int iy = 0; iy < image->numRows; iy++) {529 for (int ix = 0; ix < image->numCols; ix++) {530 dx = ix + image->col0 - x;531 dy = iy + image->row0 - y;532 r2 = PS_SQR(dx) + PS_SQR(dy);533 if (r2 <= R2) {534 if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {535 image->data.PS_TYPE_MASK_DATA[iy][ix] &= maskValue;536 } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {537 image->data.PS_TYPE_MASK_DATA[iy][ix] |= maskValue;538 } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {539 image->data.PS_TYPE_MASK_DATA[iy][ix] = maskValue;540 } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {541 image->data.PS_TYPE_MASK_DATA[iy][ix] ^= maskValue;542 } else {543 psError(PS_ERR_BAD_PARAMETER_VALUE,true,544 "The logical operation specified is incorrect\n");545 return;546 }547 }548 }549 }550 }551 552 // mask the area contained by the region553 // the region is defined wrt the parent image554 void psImageKeepCircle(psImage *image,555 double x,556 double y,557 double radius,558 const char *op,559 psMaskType maskValue)560 {561 562 double dx, dy, r2, R2;563 564 R2 = PS_SQR(radius);565 566 for (int iy = 0; iy < image->numRows; iy++) {567 for (int ix = 0; ix < image->numCols; ix++) {568 dx = ix + image->col0 - x;569 dy = iy + image->row0 - y;570 r2 = PS_SQR(dx) + PS_SQR(dy);571 if (r2 > R2) {572 if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {573 image->data.PS_TYPE_MASK_DATA[iy][ix] &= maskValue;574 } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {575 image->data.PS_TYPE_MASK_DATA[iy][ix] |= maskValue;576 } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {577 image->data.PS_TYPE_MASK_DATA[iy][ix] = maskValue;578 } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {579 image->data.PS_TYPE_MASK_DATA[iy][ix] ^= maskValue;580 } else {581 psError(PS_ERR_BAD_PARAMETER_VALUE,true,582 "The logical operation specified is incorrect\n");583 return;584 }585 }586 }587 }588 }589 -
trunk/psLib/src/imageops/psImagePixelManip.h
r5064 r5227 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2005- 09-16 23:56:48$10 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-10-06 02:41:07 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 87 87 const char *op ///< the operation to perform for overlay 88 88 ); 89 /** Sets the bits inside the region, ignoring pixels outside.90 *91 * The pixels are set by combining the existing pixel value and the given maskValue92 * with a logical operation. The allowed operations are =, AND, OR, and XOR.93 */94 void psImageMaskRegion(95 psImage *image, ///< the image to set96 psRegion region, ///< the specified region97 const char *op, ///< the logical operation98 psMaskType maskValue ///< the specified bits99 );100 101 /** Sets the bits outside the region, ignoring pixels inside.102 *103 * The pixels are set by combining the existing pixel value and the given maskValue104 * with a logical operation. The allowed operations are =, AND, OR, and XOR.105 */106 void psImageKeepRegion(107 psImage *image, ///< the image to set108 psRegion region, ///< the specified region109 const char *op, ///< the logical operation110 psMaskType maskValue ///< the specified bits111 );112 113 /** Sets the bits inside the circle, ignoring the pixels outside.114 *115 * The pixel values are set by combining the existing pixel value and the given maskValue116 * with a logical operation. The allowed operations are =, AND, OR, and XOR.117 */118 void psImageMaskCircle(119 psImage *image, ///< the image to set120 double x, ///< the x coordinate of the circle's center121 double y, ///< the y coordinate of the circle's center122 double radius, ///< the radius of the specified circle123 const char *op, ///< the logical operation124 psMaskType maskValue ///< the specified bits125 );126 127 /** Sets the bits outside the circle, ignoring the pixels inside.128 *129 * The pixel values are set by combining the existing pixel value and the given maskValue130 * with a logical operation. The allowed operations are =, AND, OR, and XOR.131 */132 void psImageKeepCircle(133 psImage *image, ///< the image to set134 double x, ///< the x coordinate of the circle's center135 double y, ///< the y coordinate of the circle's center136 double radius, ///< the radius of the specified circle137 const char *op, ///< the logical operation138 psMaskType maskValue ///< the specified bits139 );140 89 141 90 #endif // #ifndef PS_IMAGE_PIXEL_MANIP_H
Note:
See TracChangeset
for help on using the changeset viewer.
