IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 1, 2007, 6:14:33 PM (19 years ago)
Author:
gusciora
Message:

Added tabular file of all psLib functions in Chapter 6 of the SDRS (Data
Manipulation). Most of the test file changes in this check-in are fairly
cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/imageops/tap_psImageStructManip.c

    r11688 r13123  
    1 /** @file  tst_psImageExtraction.c
     1/** @file  tap_psImageStructManip.c
    22*
    33*  @brief Contains the tests for psImageExtraction.[ch]
    44*
    5 *
    65*  @author Robert DeSonia, MHPCC
    76*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2007-02-08 01:21:50 $
     7*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2007-05-02 04:14:33 $
    109*
    1110*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2625    // psImageSubset shall create child image of a specified size from a
    2726    // parent psImage structure
    28 
    2927    // psImageSubset()
    3028    {
     
    3331        psS32 c = 128;
    3432        psS32 r = 256;
    35         psRegion region1 = psRegionSet(0,c/2,0,r/2);
    36         psRegion region2 = psRegionSet(c/4,c/4+c/2,r/4,r/4+r/2);
     33        psRegion region1 = psRegionSet(0, c/2, 0, r/2);
     34        psRegion region2 = psRegionSet(c/4, c/4+c/2, r/4, r/4+r/2);
    3735
    3836        psImage* original = psImageAlloc(c,r,PS_TYPE_U32);
    39         for (psS32 row=0;row<r;row++)
    40         {
     37        for (psS32 row=0;row<r;row++) {
    4138            for (psS32 col=0;col<c;col++) {
    4239                original->data.F32[row][col] = row*1000+col;
     
    6360
    6461        bool errorFlag = false;
    65         for (psS32 row=0;row<r/2;row++)
    66         {
     62        for (psS32 row=0;row<r/2;row++) {
    6763            for (psS32 col=0;col<c/2;col++) {
    6864                if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) {
     
    9995        ok(subset2->children == NULL && subset3->children == NULL, "psImageSubset() set ->children correctly");
    10096
    101 
    10297        // Verify the input psImage structure image only has the following members
    10398        // changed: 1) Nchildren is increased by one. 2) parent contains pointer psImage structure
     
    107102           "psImageSubset did properly store the children pointers.");
    108103
     104
    109105        // Verify the returned psImage structure pointer is null and program
    110106        // execution doesn't stop, if the input parameter image is null.
     
    114110        psImage* subset1 = psImageSubset(NULL,region1);
    115111        ok(subset1 == NULL, "psImageSubset returned NULL when input image was NULL.");
     112
    116113
    117114        // Verify the returned psImage structure pointer is null and program
     
    153150        ok(subset1 == NULL,
    154151           "psImageSubset returned NULL when subset origin was outside of image (row0=-1)");
     152
    155153
    156154        // Verify the returned psImage structure pointer is null and program
     
    205203        psU32 r = 256;
    206204
    207         psImage* img = psImageAlloc(c,r,PS_TYPE_F32);
    208         for (unsigned row=0;row<r;row++)
    209         {
    210             psF32* imgRow = img->data.F32[row];
     205        psImage *img = psImageAlloc(c,r,PS_TYPE_F32);
     206        for (unsigned row=0;row<r;row++) {
    211207            for (unsigned col=0;col<c;col++) {
    212                 imgRow[col] = (psF32)(row+col);
    213             }
    214         }
    215         psImage* img2 = psImageAlloc(c,r,PS_TYPE_F32);
    216         for (unsigned row=0;row<r;row++)
    217         {
    218             psF32* img2Row = img2->data.F32[row];
     208                img->data.F32[row][col] = (psF32)(row+col);
     209            }
     210        }
     211        psImage *img2 = psImageAlloc(c,r,PS_TYPE_F32);
     212        for (unsigned row=0;row<r;row++) {
    219213            for (unsigned col=0;col<c;col++) {
    220                 img2Row[col] = 0.0f;
    221             }
    222         }
    223 
    224         psImage* img3 = psImageCopy(img2,img,PS_TYPE_F32);
    225         // Verify the returned psImage structure pointer is equal to the input parameter output.
     214                img2->data.F32[row][col] = 0.0f;
     215            }
     216        }
     217
     218        psImage *img3 = psImageCopy(img2,img,PS_TYPE_F32);
     219        // Verify the returned psImage structure pointer is equal to the input
     220        // parameter output.
    226221        ok(img2 == img3, "psImageCopy(): recycled input image");
    227222
    228         // Verify the returned psImage structure is the same type as the input image structure
    229         // if the specified output argument is NULL.
    230         psImage* img4 = psImageCopy(NULL,img,PS_TYPE_F32);
     223        // Verify the returned psImage structure is the same type as the input image
     224        // structure if the specified output argument is NULL.
     225        psImage *img4 = psImageCopy(NULL,img,PS_TYPE_F32);
    231226        ok(img4 != NULL, "psImageCopy() returned non-NULL with NULL output argument");
    232227        ok(img4->type.type == img->type.type, "psImageCopy() set the correct image type");
    233228        bool errorFlag = false;
    234         for (psU32 row=0;row<r;row++)
    235         {
     229        for (psU32 row=0;row<r;row++) {
    236230            psF32* imgInRow = img->data.F32[row];
    237231            psF32* imgOutRow = img4->data.F32[row];
     
    326320        psS32 halfR = r/2;
    327321        psS32 halfC = c/2;
    328         psRegion centerHalf = {qtrC,qtrC+halfC,qtrR,qtrR+halfR};
     322        psRegion centerHalf = {qtrC, qtrC+halfC, qtrR, qtrR+halfR};
    329323
    330324        psImage* image = psImageAlloc(c,r,PS_TYPE_F32);
    331         for (psS32 row = 0; row < image->numRows; row++)
    332         {
     325        for (psS32 row = 0; row < image->numRows; row++) {
    333326            for (psS32 col = 0; col < image->numCols; col++) {
    334327                image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f;
    335328            }
    336329        }
    337 
    338330        // invoke psImageTrim with non-NULL image, and a valid region
    339331        // x0,y0->x1,y1 (using only positive values). Verify that:
     
    350342
    351343        bool errorFlag = false;
    352         for (psS32 row = 0; row < image2->numRows; row++)
    353         {
     344        for (psS32 row = 0; row < image2->numRows; row++) {
    354345            for (psS32 col = 0; col < image2->numCols; col++) {
    355346                if (fabsf(image2->data.F32[row][col] - image->data.F32[row+qtrR][col+qtrC])
     
    379370           image->numCols-qtrC, image->numRows-qtrR);
    380371
    381         for (psS32 row = 0; row < image2->numRows; row++)
    382         {
     372        for (psS32 row = 0; row < image2->numRows; row++) {
    383373            for (psS32 col = 0; col < image2->numCols; col++) {
    384374                if (fabsf(image2->data.F32[row][col] -
     
    394384        ok(!errorFlag, "psImageTrim() set image data correctly");
    395385
    396         //  4. invoke psImageTrim with x1<0, y1<0. Verify:
     386
     387        //  Invoke psImageTrim with x1<0, y1<0. Verify:
    397388        //      a. the psImage size is (numCols+x1)-x0 by (numRows+y1)-y0.
    398389        //      b. the pixel values coorespond to the region
     
    405396           image2->numCols, image2->numRows,
    406397           image->numCols-qtrC, image->numRows-qtrR);
    407 
    408         for (psS32 row = 0; row < image2->numRows; row++)
    409         {
     398        for (psS32 row = 0; row < image2->numRows; row++) {
    410399            for (psS32 col = 0; col < image2->numCols; col++) {
    411400                if (fabsf(image2->data.F32[row][col] -
     
    422411        psFree(image1);
    423412
    424         //  6. invoke psImageTrim with image=NULL Verify:
     413
     414        //  Invoke psImageTrim with image=NULL Verify:
    425415        //      a. execution does not cease.
    426416        //      b. return value is NULL
     
    428418        // An error should follow...
    429419        // XXX: Verify errors
    430 
    431 
    432420        image2 = psImageTrim(NULL, psRegionSet(qtrC,0,qtrR,0));
    433421        ok(image2 == NULL, "psImageTrim returned NULL given a NULL input image");
     
    438426
    439427
     428        // Verify when psRegion has a coord at -1
    440429        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    441430        image2 = psImageTrim(image1, psRegionSet(-1,0,0,0));
     
    447436
    448437
     438        // Verify when psRegion has a coord at -1
    449439        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    450440        image2 = psImageTrim(image1, psRegionSet(0,0,-1,0));
     
    456446
    457447
     448        // Verify when psRegion has a coord at outside the image range
    458449        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    459450        image2 = psImageTrim(image1, psRegionSet(0,image->numCols+1,0,0));
     
    465456
    466457
     458        // Verify when psRegion has a coord at outside the image range
    467459        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    468460        image2 = psImageTrim(image1, psRegionSet(0,0,0,image->numRows+1));
     
    474466
    475467
     468        // Verify when psRegion has a coord at outside the image range
    476469        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    477470        image2 = psImageTrim(image1, psRegionSet(0,0,0,(((psF32)image->numRows)*-1.0)));
     
    483476
    484477
     478        // Verify when psRegion has a coord at outside the image range
    485479        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    486480        image2 = psImageTrim(image1, psRegionSet(0,(((psF32)image->numCols)*-1.0),0,0));
Note: See TracChangeset for help on using the changeset viewer.