IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5101


Ignore:
Timestamp:
Sep 22, 2005, 2:04:36 PM (21 years ago)
Author:
drobbin
Message:

Added and update PixelGet/Set, ImageGet/Set, and test fxns

Location:
trunk/psLib
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/mathtypes/psImage.c

    r5064 r5101  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.83 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-09-16 23:56:51 $
     11 *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-09-23 00:04:36 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    267267}
    268268
     269bool psImageSet(const psImage *image,
     270                int x,
     271                int y,
     272                complex value)
     273{
     274    if (image == NULL)
     275        return false;
     276    if (x >= image->numRows || y >= image->numCols)
     277        return false;
     278    if(x < 0)
     279        x += image->numRows;
     280    if(y < 0)
     281        y += image->numCols;
     282
     283    switch (image->type.type) {
     284    case PS_TYPE_U8:
     285        *(psU8*)&image->data.U8[x][y] = value;
     286        break;
     287    case PS_TYPE_U16:
     288        *(psU16*)&image->data.U16[x][y] = value;
     289        break;
     290    case PS_TYPE_U32:
     291        *(psU32*)&image->data.U32[x][y] = value;
     292        break;
     293    case PS_TYPE_U64:
     294        *(psU64*)&image->data.U64[x][y] = value;
     295        break;
     296    case PS_TYPE_S8:
     297        *(psS8*)&image->data.S8[x][y] = value;
     298        break;
     299    case PS_TYPE_S16:
     300        *(psS16*)&image->data.S16[x][y] = value;
     301        break;
     302    case PS_TYPE_S32:
     303        *(psS32*)&image->data.S32[x][y] = value;
     304        break;
     305    case PS_TYPE_S64:
     306        *(psS64*)&image->data.S64[x][y] = value;
     307        break;
     308    case PS_TYPE_F32:
     309        *(psF32*)&image->data.F32[x][y] = value;
     310        break;
     311    case PS_TYPE_F64:
     312        *(psF64*)&image->data.F64[x][y] = value;
     313        break;
     314    case PS_TYPE_C32:
     315        *(psC32*)&image->data.C32[x][y] = value;
     316        break;
     317    case PS_TYPE_C64:
     318        *(psC64*)&image->data.C64[x][y] = value;
     319        break;
     320    default:
     321        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psImage Data Type\n");
     322        return false;
     323    }
     324
     325    return true;
     326}
     327
     328complex psImageGet(const psImage *image,
     329                   int x,
     330                   int y)
     331{
     332    if (image == NULL)
     333        return NAN;
     334    if (x >= image->numRows || y >= image->numCols)
     335        return NAN;
     336    if(x < 0)
     337        x += image->numRows;
     338    if(y < 0)
     339        y += image->numCols;
     340
     341    switch (image->type.type) {
     342    case PS_TYPE_U8:
     343        return image->data.U8[x][y];
     344        break;
     345    case PS_TYPE_U16:
     346        return image->data.U16[x][y];
     347        break;
     348    case PS_TYPE_U32:
     349        return image->data.U32[x][y];
     350        break;
     351    case PS_TYPE_U64:
     352        return image->data.U64[x][y];
     353        break;
     354    case PS_TYPE_S8:
     355        return image->data.S8[x][y];
     356        break;
     357    case PS_TYPE_S16:
     358        return image->data.S16[x][y];
     359        break;
     360    case PS_TYPE_S32:
     361        return image->data.S32[x][y];
     362        break;
     363    case PS_TYPE_S64:
     364        return image->data.S64[x][y];
     365        break;
     366    case PS_TYPE_F32:
     367        return image->data.F32[x][y];
     368        break;
     369    case PS_TYPE_F64:
     370        return image->data.F64[x][y];
     371        break;
     372    case PS_TYPE_C32:
     373        return image->data.C32[x][y];
     374        break;
     375    case PS_TYPE_C64:
     376        return image->data.C64[x][y];
     377        break;
     378    default:
     379        return NAN;
     380    }
     381}
    269382
    270383psImage* psImageRecycle(psImage* old,
  • trunk/psLib/src/mathtypes/psImage.h

    r5070 r5101  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.70 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-09-19 22:50:29 $
     13 *  @version $Revision: 1.71 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-09-23 00:04:36 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    193193);
    194194
     195/** Sets the value of the image at the specified x,y position to value.
     196 *
     197 *  A negative value for the x or y positions means index from the end.
     198 *
     199 *  @return bool:       True on success, otherwise false.
     200 */
     201bool psImageSet(
     202    const psImage *image,              ///< the image to set
     203    int x,                             ///< x-position
     204    int y,                             ///< y-position
     205    complex value                      ///< specified value to set
     206);
     207
     208/** Returns the value of the image at the specified x,y position.
     209 *
     210 *  A negative value for the x or y positions means index from the end.
     211 *
     212 *  @return complex:        The value at the specified x,y position.
     213 */
     214complex psImageGet(
     215    const psImage *image,              ///< the image from which to get
     216    int x,                             ///< x-position
     217    int y                              ///< y-position
     218);
     219
    195220/** Resize a given image to the given size/type.
    196221 *
  • trunk/psLib/src/mathtypes/psVector.c

    r5089 r5101  
    99*  @author Robert DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-09-22 02:32:00 $
     11*  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-09-23 00:04:36 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    863863    default:
    864864        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psVector Data Type\n");
     865        return false;
    865866    }
    866867
  • trunk/psLib/src/types/psPixels.c

    r4898 r5101  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-08-30 01:14:13 $
     9 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-23 00:04:36 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    332332    return (true);
    333333}
     334
     335bool psPixelsSet(psPixels *pixels,
     336                 long position,
     337                 psPixelCoord value)
     338{
     339    if (pixels == NULL)
     340        return false;
     341    if (position > pixels->n)
     342        return false;
     343    if(position < 0)
     344        position += pixels->n;
     345    if (position == pixels->n) {
     346        if (position >= pixels->nalloc)
     347            return false;
     348        pixels->n++;
     349    }
     350    pixels->data[position].x = value.x;
     351    pixels->data[position].y = value.y;
     352
     353    return true;
     354}
     355
     356psPixelCoord psPixelsGet(const psPixels *pixels,
     357                         long position)
     358{
     359    psPixelCoord out;
     360    if (pixels == NULL) {
     361        out.x = 0; //XXX: should be NAN when changed to float
     362        out.y = 0; //XXX: should be NAN when changed to float
     363        return out;
     364    }
     365    if (position >= pixels->n) {
     366        out.x = 0; //XXX: should be NAN when changed to float
     367        out.y = 0; //XXX: should be NAN when changed to float
     368        return out;
     369    }
     370    if (position < 0)
     371        position += pixels->n;
     372    out.x = pixels->data[position].x;
     373    out.y = pixels->data[position].y;
     374    return out;
     375}
     376
  • trunk/psLib/src/types/psPixels.h

    r4898 r5101  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-08-30 01:14:13 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-23 00:04:36 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    161161);
    162162
     163/** Sets the value of the the pixels array at the specified position to value.
     164 *
     165 *  A negative position means index from the end.
     166 *
     167 *  @return bool:       True if Successful, otherwise false.
     168*/
     169bool psPixelsSet(
     170    psPixels *pixels,                  ///< pixels to set
     171    long position,                     ///< position to set
     172    psPixelCoord value                 ///< pixels value to be set
     173);
     174
     175/** Returns the value of the pixels array at the specified position.
     176 *
     177 *  A negative position means index from the end.
     178 *
     179 *  @return psPixelCoord:       The value of the pixels at the specified position.
     180*/
     181psPixelCoord psPixelsGet(
     182    const psPixels *pixels,            ///< input pixels from which to get
     183    long position                      ///< position to get
     184);
     185
    163186#endif // #ifndef PS_PIXELS_H
  • trunk/psLib/test/mathtypes/tst_psImage.c

    r5064 r5101  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-09-16 23:56:51 $
     8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-09-23 00:04:36 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2626static psS32 testRegion3(void);
    2727static psS32 testImageInit(void);
     28static psS32 testImageGetSet(void);
    2829
    2930testDescription tests[] = {
     
    3536                              {testRegion3,793,"psRegionForSquare",0,false},
    3637                              {testImageInit,794,"psImageInit",0,false},
     38                              {testImageGetSet,795,"psImageInit",0,false},
    3739                              {NULL}
    3840                          };
     
    354356}
    355357
     358static psS32 testImageGetSet(void)
     359{
     360    psImage *image = NULL;
     361    image = psImageAlloc(5, 5, PS_TYPE_S32);
     362
     363    if ( !psImageSet(image, 0, 0, 10) )
     364        fprintf(stderr, "ImageSet failed to set S32 at position 0\n");
     365    if ( psImageSet(image, 10, 10, 100) )
     366        fprintf(stderr, "ImageSet Improperly set S32 at out of range position\n");
     367    if ( !psImageSet(image, -1, -1, 4) )
     368        fprintf(stderr, "ImageSet Failed to set S32 at position 4,4\n");
     369    if ( (psS32)psImageGet(image, 0, 0) != 10 )
     370        fprintf(stderr, "ImageGet Failed to return the correct S32 from position 0,0\n");
     371    if ( (psS32)psImageGet(image, -1, -1) != 4 )
     372        fprintf(stderr, "ImageGet Failed to return the correct S32 from tail using -1,-1\n");
     373
     374    psFree(image);
     375    return 0;
     376}
  • trunk/psLib/test/mathtypes/verified/tst_psImage.stderr

    r4887 r5101  
    132132---> TESTPOINT PASSED (psImage{psImageInit} | tst_psImage.c)
    133133
     134/***************************** TESTPOINT ******************************************\
     135*             TestFile: tst_psImage.c                                              *
     136*            TestPoint: psImage{psImageInit}                                       *
     137*             TestType: Positive                                                   *
     138\**********************************************************************************/
     139
     140
     141---> TESTPOINT PASSED (psImage{psImageInit} | tst_psImage.c)
     142
  • trunk/psLib/test/types/tst_psPixels.c

    r4547 r5101  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.1 $
     7 *  @version $Revision: 1.2 $
    88 *           $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-07-13 02:47:01 $
     9 *  @date $Date: 2005-09-23 00:04:36 $
    1010 *
    1111 *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    2121static int testPixelsFromMask(void);
    2222static int testPixelsConcatenate(void);
     23static psS32 testPixelsGetSet(void);
    2324
    2425testDescription tests[] = {
     
    2930                              {testPixelsFromMask,865,"psPixelsFromMask",0,false},
    3031                              {testPixelsConcatenate,866,"psPixelsConcatenate",0,false},
     32                              {testPixelsGetSet,867,"psPixelsGet/Set",0,false},
    3133                              {NULL}
    3234                          };
     
    502504}
    503505
     506psS32 testPixelsGetSet(void)
     507{
     508    psPixels *in = psPixelsAlloc(5);
     509    in->n = 0;
     510    psPixelCoord value;
     511    psPixelCoord out;
     512    value.x = 3;
     513    value.y = 13;
     514    if ( psPixelsSet(in, 2, value) ) {
     515        psError(PS_ERR_LOCATION_INVALID, true, "psPixelSet set to Invalid location\n");
     516        return 1;
     517    }
     518    if ( !psPixelsSet(in, 0, value) ) {
     519        psError(PS_ERR_UNKNOWN, true, "psPixelsSet failed to set pixels at location 0\n");
     520        return 2;
     521    }
     522    if ( !psPixelsSet(in, 1, value) ) {
     523        psError(PS_ERR_UNKNOWN, true, "psPixelsSet failed to set pixels at location 0\n");
     524        return 3;
     525    }
     526    out = psPixelsGet(in, 1);
     527    if ( out.x != 3 || out.y != 13 ) {
     528        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPixelsGet return incorrect values %d,%d",
     529                out.x, out.y);
     530        return 4;
     531    }
     532    value.x = 1;
     533    value.y = 2;
     534    if ( !psPixelsSet(in, 0, value) ) {
     535        psError(PS_ERR_UNKNOWN, true, "psPixelsSet failed to set pixels at location 0\n");
     536        return 5;
     537    }
     538    out = psPixelsGet(in, 0);
     539    if (out.x != 1 || out.y != 2) {
     540        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPixelsGet return incorrect values %d,%d",
     541                out.x, out.y);
     542        return 6;
     543    }
     544    psFree(in);
     545    return 0;
     546}
     547
  • trunk/psLib/test/types/verified/tst_psPixels.stderr

    r4547 r5101  
    7373---> TESTPOINT PASSED (psPixels{psPixelsConcatenate} | tst_psPixels.c)
    7474
     75/***************************** TESTPOINT ******************************************\
     76*             TestFile: tst_psPixels.c                                             *
     77*            TestPoint: psPixels{psPixelsGet/Set}                                  *
     78*             TestType: Positive                                                   *
     79\**********************************************************************************/
     80
     81
     82---> TESTPOINT PASSED (psPixels{psPixelsGet/Set} | tst_psPixels.c)
     83
Note: See TracChangeset for help on using the changeset viewer.