IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5224


Ignore:
Timestamp:
Oct 4, 2005, 5:51:43 PM (21 years ago)
Author:
drobbin
Message:

Updated/fixed Image Mask/Keep fxns and implemented tests

Location:
trunk/psLib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psTime.c

    r5222 r5224  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-10-04 01:31:40 $
     12 *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-10-05 03:51:41 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    11511151        jd = time->sec / SEC_PER_DAY + time->nsec / NSEC_PER_DAY + JD_EPOCH_OFFSET;
    11521152    }
    1153 
    11541153    return jd;
    11551154}
     
    11711170        mjd = time->sec / SEC_PER_DAY + time->nsec / NSEC_PER_DAY + MJD_EPOCH_OFFSET;
    11721171    }
    1173 
    11741172    return mjd;
    11751173}
  • trunk/psLib/src/imageops/psImagePixelManip.c

    r5064 r5224  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-09-16 23:56:48 $
     12 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-10-05 03:51:43 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    403403                       psMaskType maskValue)
    404404{
    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 ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {
    417                 image->data.U8[iy][ix] &= maskValue;
    418             } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {
    419                 image->data.U8[iy][ix] |= maskValue;
    420             } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {
    421                 image->data.U8[iy][ix] = maskValue;
    422             } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {
    423                 image->data.U8[iy][ix] ^= maskValue;
     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                }
    424424            }
    425425        }
    426426    }
     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    */
    427450}
    428451
     
    434457                       psMaskType maskValue)
    435458{
    436 
    437     for (int iy = 0; iy < image->numRows; iy++) {
    438         for (int ix = 0; ix < image->numCols; ix++) {
    439             if (ix + image->col0 <  region.x0)
    440                 goto maskit;
    441             if (ix + image->col0 >= region.x1)
    442                 goto maskit;
    443             if (iy + image->row0 <  region.y0)
    444                 goto maskit;
    445             if (iy + image->row0 >= region.y1)
    446                 goto maskit;
    447             continue;
    448 maskit:
    449             if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {
    450                 image->data.U8[iy][ix] &= maskValue;
    451             } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {
    452                 image->data.U8[iy][ix] |= maskValue;
    453             } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {
    454                 image->data.U8[iy][ix] = maskValue;
    455             } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {
    456                 image->data.U8[iy][ix] ^= maskValue;
     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                }
    457478            }
    458479        }
    459480    }
     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    */
    460506}
    461507
     
    469515                       psMaskType maskValue)
    470516{
     517    if (image == NULL) {
     518        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     519                "Invalid image input.  Image is NULL.\n");
     520        return;
     521    }
     522
    471523
    472524    double dx, dy, r2, R2;
     
    479531            dy = iy + image->row0 - y;
    480532            r2 = PS_SQR(dx) + PS_SQR(dy);
    481             if (r2 > R2)
    482                 continue;
    483             if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {
    484                 image->data.U8[iy][ix] &= maskValue;
    485             } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {
    486                 image->data.U8[iy][ix] |= maskValue;
    487             } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {
    488                 image->data.U8[iy][ix] = maskValue;
    489             } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {
    490                 image->data.U8[iy][ix] ^= maskValue;
     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                }
    491547            }
    492548        }
     
    513569            dy = iy + image->row0 - y;
    514570            r2 = PS_SQR(dx) + PS_SQR(dy);
    515             if (r2 < R2)
    516                 continue;
    517             if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {
    518                 image->data.U8[iy][ix] &= maskValue;
    519             } else if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {
    520                 image->data.U8[iy][ix] |= maskValue;
    521             } else if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {
    522                 image->data.U8[iy][ix] = maskValue;
    523             } else if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {
    524                 image->data.U8[iy][ix] ^= maskValue;
     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                }
    525585            }
    526586        }
  • trunk/psLib/test/imageops/tst_psImagePixelManip.c

    r4547 r5224  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-07-13 02:47:00 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-10-05 03:51:43 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2929static psS32 testImageClipComplexRegion(void);
    3030static psS32 testImageOverlay(void);
     31static psS32 testImageKeepMask(void);
    3132
    3233testDescription tests[] = {
     
    3536                              {testImageClipComplexRegion,673,"psImageClipComplexRegion",0,false},
    3637                              {testImageOverlay,573,"psImageOverlay",0,false},
     38                              {testImageKeepMask,574,"psImageKeep and Mask",0,false},
    3739                              {NULL}
    3840                          };
     
    796798    return 0;
    797799}
     800
     801psS32 testImageKeepMask(void)
     802{
     803    //psImageMaskRegion
     804    //psImageKeepRegion
     805    //psImageMaskCircle
     806    //psImageKeepCircle
     807    psImage *in = psImageAlloc(3,3,PS_TYPE_MASK);
     808    psRegion reg;
     809    reg.x0 = 0;
     810    reg.x1 = 1;
     811    reg.y0 = 0;
     812    reg.y1 = 1;
     813    psMaskType mask = 2;
     814    in->data.PS_TYPE_MASK_DATA[0][0] = 2;
     815    in->data.PS_TYPE_MASK_DATA[0][1] = 0;
     816    in->data.PS_TYPE_MASK_DATA[0][2] = 1;
     817    in->data.PS_TYPE_MASK_DATA[1][0] = 4;
     818    in->data.PS_TYPE_MASK_DATA[1][1] = 0;
     819    in->data.PS_TYPE_MASK_DATA[1][2] = 3;
     820    in->data.PS_TYPE_MASK_DATA[2][0] = 2;
     821    in->data.PS_TYPE_MASK_DATA[2][1] = 1;
     822    in->data.PS_TYPE_MASK_DATA[2][2] = 2;
     823
     824    printf("\n Mask Region------");
     825    psImageMaskRegion(in, reg, "|", mask);
     826    for(int i = 0; i < 3; i++) {
     827        for (int j = 0; j < 3; j++) {
     828            printf("\nin->data.u8 [i][j] i=%d, j=%d = %u", i, j, in->data.PS_TYPE_MASK_DATA[i][j]);
     829        }
     830    }
     831
     832    in->data.PS_TYPE_MASK_DATA[0][0] = 2;
     833    in->data.PS_TYPE_MASK_DATA[0][1] = 0;
     834    in->data.PS_TYPE_MASK_DATA[0][2] = 1;
     835    in->data.PS_TYPE_MASK_DATA[1][0] = 4;
     836    in->data.PS_TYPE_MASK_DATA[1][1] = 0;
     837    in->data.PS_TYPE_MASK_DATA[1][2] = 3;
     838    in->data.PS_TYPE_MASK_DATA[2][0] = 2;
     839    in->data.PS_TYPE_MASK_DATA[2][1] = 1;
     840    in->data.PS_TYPE_MASK_DATA[2][2] = 2;
     841    psImageKeepRegion(in, reg, "AND", mask);
     842    printf("\n Keep Region------");
     843    for(int i = 0; i < 3; i++) {
     844        for (int j = 0; j < 3; j++) {
     845            printf("\nin->data.u8 [i][j] i=%d, j=%d = %u", i, j, in->data.PS_TYPE_MASK_DATA[i][j]);
     846        }
     847    }
     848
     849    //Mask Circle and Keep Circle Functions
     850    in->data.PS_TYPE_MASK_DATA[0][0] = 2;
     851    in->data.PS_TYPE_MASK_DATA[0][1] = 0;
     852    in->data.PS_TYPE_MASK_DATA[0][2] = 1;
     853    in->data.PS_TYPE_MASK_DATA[1][0] = 4;
     854    in->data.PS_TYPE_MASK_DATA[1][1] = 0;
     855    in->data.PS_TYPE_MASK_DATA[1][2] = 3;
     856    in->data.PS_TYPE_MASK_DATA[2][0] = 2;
     857    in->data.PS_TYPE_MASK_DATA[2][1] = 1;
     858    in->data.PS_TYPE_MASK_DATA[2][2] = 2;
     859    psImageMaskCircle(in, 1, 1, 1, "XOR", mask);
     860    printf("\n Mask Circle------");
     861    for(int i = 0; i < 3; i++) {
     862        for (int j = 0; j < 3; j++) {
     863            printf("\nin->data.u8 [i][j] i=%d, j=%d = %u", i, j, in->data.PS_TYPE_MASK_DATA[i][j]);
     864        }
     865    }
     866
     867    in->data.PS_TYPE_MASK_DATA[0][0] = 2;
     868    in->data.PS_TYPE_MASK_DATA[0][1] = 0;
     869    in->data.PS_TYPE_MASK_DATA[0][2] = 1;
     870    in->data.PS_TYPE_MASK_DATA[1][0] = 4;
     871    in->data.PS_TYPE_MASK_DATA[1][1] = 0;
     872    in->data.PS_TYPE_MASK_DATA[1][2] = 3;
     873    in->data.PS_TYPE_MASK_DATA[2][0] = 2;
     874    in->data.PS_TYPE_MASK_DATA[2][1] = 1;
     875    in->data.PS_TYPE_MASK_DATA[2][2] = 2;
     876    psImageKeepCircle(in, 1, 1, 1, "=", mask);
     877    printf("\n Keep Circle------");
     878    for(int i = 0; i < 3; i++) {
     879        for (int j = 0; j < 3; j++) {
     880            printf("\nin->data.u8 [i][j] i=%d, j=%d = %u", i, j, in->data.PS_TYPE_MASK_DATA[i][j]);
     881        }
     882    }
     883    fflush(stdout);
     884
     885    //Error Checks
     886    //incorrect logical operation
     887    printf("\n");
     888    psImageKeepRegion(in, reg, "+", mask);
     889    //null image
     890    psImage *none = NULL;
     891    psImageMaskCircle(none, 1, 1, 1, "&", mask);
     892
     893    psFree(in);
     894    return 0;
     895}
     896
  • trunk/psLib/test/imageops/verified/tst_psImagePixelManip.stderr

    r4877 r5224  
    147147---> TESTPOINT PASSED (psImage{psImageOverlay} | tst_psImagePixelManip.c)
    148148
     149/***************************** TESTPOINT ******************************************\
     150*             TestFile: tst_psImagePixelManip.c                                    *
     151*            TestPoint: psImage{psImageKeep and Mask}                              *
     152*             TestType: Positive                                                   *
     153\**********************************************************************************/
     154
     155<DATE><TIME>|<HOST>|E|psImageKeepRegion (FILE:LINENO)
     156    The logical operation specified is incorrect
     157<DATE><TIME>|<HOST>|E|psImageMaskCircle (FILE:LINENO)
     158    Invalid image input.  Image is NULL.
     159
     160---> TESTPOINT PASSED (psImage{psImageKeep and Mask} | tst_psImagePixelManip.c)
     161
Note: See TracChangeset for help on using the changeset viewer.