IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 18, 2005, 11:44:40 AM (21 years ago)
Author:
drobbin
Message:

folded in code from bug 481. Tests still to be written.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImagePixelManip.c

    r4589 r4815  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-07-21 01:40:10 $
     12 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-08-18 21:44:40 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    396396}
    397397
     398// mask the area contained by the region
     399// the region is defined wrt the parent image
     400void psImageMaskRegion(psImage *image,
     401                       psRegion *region,
     402                       bool logical_and,
     403                       int maskValue)
     404{
     405
     406    for (int iy = 0; iy < image->numRows; iy++) {
     407        for (int ix = 0; ix < image->numCols; ix++) {
     408            if (ix + image->col0 <  region->x0)
     409                continue;
     410            if (ix + image->col0 >= region->x1)
     411                continue;
     412            if (iy + image->row0 <  region->y0)
     413                continue;
     414            if (iy + image->row0 >= region->y1)
     415                continue;
     416            if (logical_and) {
     417                image->data.U8[iy][ix] &= maskValue;
     418            } else {
     419                image->data.U8[iy][ix] |= maskValue;
     420            }
     421        }
     422    }
     423}
     424
     425// mask the area not contained by the region
     426// the region is defined wrt the parent image
     427void psImageKeepRegion(psImage *image,
     428                       psRegion *region,
     429                       bool logical_and,
     430                       int maskValue)
     431{
     432
     433    for (int iy = 0; iy < image->numRows; iy++) {
     434        for (int ix = 0; ix < image->numCols; ix++) {
     435            if (ix + image->col0 <  region->x0)
     436                goto maskit;
     437            if (ix + image->col0 >= region->x1)
     438                goto maskit;
     439            if (iy + image->row0 <  region->y0)
     440                goto maskit;
     441            if (iy + image->row0 >= region->y1)
     442                goto maskit;
     443            continue;
     444maskit:
     445            if (logical_and) {
     446                image->data.U8[iy][ix] &= maskValue;
     447            } else {
     448                image->data.U8[iy][ix] |= maskValue;
     449            }
     450        }
     451    }
     452}
     453
     454// mask the area contained by the region
     455// the region is defined wrt the parent image
     456void psImageMaskCircle(psImage *image,
     457                       double x,
     458                       double y,
     459                       double radius,
     460                       bool logical_and,
     461                       int maskValue)
     462{
     463
     464    double dx, dy, r2, R2;
     465
     466    R2 = PS_SQR(radius);
     467
     468    for (int iy = 0; iy < image->numRows; iy++) {
     469        for (int ix = 0; ix < image->numCols; ix++) {
     470            dx = ix + image->col0 - x;
     471            dy = iy + image->row0 - y;
     472            r2 = PS_SQR(dx) + PS_SQR(dy);
     473            if (r2 > R2)
     474                continue;
     475            if (logical_and) {
     476                image->data.U8[iy][ix] &= maskValue;
     477            } else {
     478                image->data.U8[iy][ix] |= maskValue;
     479            }
     480        }
     481    }
     482}
     483
     484// mask the area contained by the region
     485// the region is defined wrt the parent image
     486void psImageKeepCircle(psImage *image,
     487                       double x,
     488                       double y,
     489                       double radius,
     490                       bool logical_and,
     491                       int maskValue)
     492{
     493
     494    double dx, dy, r2, R2;
     495
     496    R2 = PS_SQR(radius);
     497
     498    for (int iy = 0; iy < image->numRows; iy++) {
     499        for (int ix = 0; ix < image->numCols; ix++) {
     500            dx = ix + image->col0 - x;
     501            dy = iy + image->row0 - y;
     502            r2 = PS_SQR(dx) + PS_SQR(dy);
     503            if (r2 < R2)
     504                continue;
     505            if (logical_and) {
     506                image->data.U8[iy][ix] &= maskValue;
     507            } else {
     508                image->data.U8[iy][ix] |= maskValue;
     509            }
     510        }
     511    }
     512}
     513
Note: See TracChangeset for help on using the changeset viewer.