IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 856


Ignore:
Timestamp:
Jun 3, 2004, 5:12:11 PM (22 years ago)
Author:
desonia
Message:

Added tests for psImageCopy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/image/tst_psImage.c

    r844 r856  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-04 00:19:54 $
     8 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-04 03:12:11 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1515#include <float.h>
    1616#include <string.h>
     17#include <stdlib.h>
    1718
    1819#include "psTest.h"
     
    3435{
    3536    psSetLogLevel(PS_LOG_INFO);
    36 
    37     testImageSubset();
    3837
    3938    if (! runTestSuite(stderr,"psImage",tests)) {
     
    549548    // Verify the returned psImage structure member are equal to the values in
    550549    // the input psImage structure input.
    551     for (unsigned row=0;row<r;row++) {
    552         psF32* imgRow = img->data.F32[row];
    553         psF32* img2Row = img2->data.F32[row];
    554         for (unsigned col=0;col<c;col++) {
    555             if (imgRow[col] - (row+col) > FLT_EPSILON) {
    556                 psError(__func__,"Input image was changed at %d,%d (%f)!",
    557                         col,row,imgRow[col]);
    558                 return 2;
    559             }
    560 
    561             if (imgRow[col] != img2Row[col]) {
    562                 psError(__func__,"returned psImage values after copy don't match!");
    563                 return 2;
    564             }
    565         }
    566     }
     550
     551    #define testImageCopyType(IN,OUT) \
     552    img = psImageRecycle(img,c,r,PS_TYPE_##IN); \
     553    for (unsigned row=0;row<r;row++) { \
     554        ps##IN* imgRow = img->data.IN[row]; \
     555        for (unsigned col=0;col<c;col++) { \
     556            imgRow[col] = (ps##IN)(row+col); \
     557        } \
     558    } \
     559    img2 = psImageCopy(img2,img,PS_TYPE_##OUT); \
     560    if (img2 == NULL) { \
     561        psError(__func__,"psImageCopy failed to copy U8."); \
     562        return 2; \
     563    } \
     564    for (unsigned int row=0;row<r;row++) { \
     565        ps##IN* imgRow = img->data.IN[row]; \
     566        ps##OUT* img2Row = img2->data.OUT[row]; \
     567        for (unsigned int col=0;col<c;col++) { \
     568            if (abs(imgRow[col] - (ps##IN)(row+col)) > 0.5) { \
     569                psError(__func__,"Input image was changed at %d,%d!", \
     570                        col,row); \
     571                return 2; \
     572            } \
     573            if (abs(img2Row[col] - (ps##OUT)(imgRow[col])) > 0.5) { \
     574                psError(__func__,"returned psImage values after copy don't match at %d,%d " \
     575                        "(%d vs %d)",\
     576                        col,row,img2Row[col], (ps##OUT)(imgRow[col])); \
     577                return 2; \
     578            } \
     579        } \
     580    }
     581
     582    #define testImageCopyTypes(IN) \
     583    testImageCopyType(IN,U8); \
     584    testImageCopyType(IN,U16); \
     585    testImageCopyType(IN,U32); \
     586    testImageCopyType(IN,S8);\
     587    testImageCopyType(IN,S16);\
     588    testImageCopyType(IN,S32);\
     589    testImageCopyType(IN,F32);\
     590    testImageCopyType(IN,F64);
     591
     592    testImageCopyTypes(U8);
     593    testImageCopyTypes(U16);
     594    testImageCopyTypes(U32);
     595    testImageCopyTypes(S8);
     596    testImageCopyTypes(S16);
     597    testImageCopyTypes(S32);
     598    testImageCopyTypes(F32);
     599    testImageCopyTypes(F64);
    567600
    568601    // Verify the returned psImage structure pointer is null and program
     
    575608    }
    576609
    577     img2 = psImageCopy(img2,img,PS_TYPE_U8);
    578     for (unsigned row=0;row<r;row++) {
    579         psF32* imgRow = img->data.F32[row];
    580         psU8* img2Row = img2->data.U8[row];
    581         for (unsigned col=0;col<c;col++) {
    582             if (imgRow[col] - (row+col) > FLT_EPSILON) {
    583                 psError(__func__,"Input image was changed at %d,%d (%f)!",
    584                         col,row,imgRow[col]);
    585                 return 2;
    586             }
    587 
    588             if (row+col != img2Row[col]) {
    589                 psError(__func__,"returned psImage values after copy don't match at %d,%d (%d vs %d)",
    590                         col,row,img2Row[col], row+col);
    591                 return 2;
    592             }
    593         }
    594     }
    595 
    596     img2 = psImageCopy(img2,img,PS_TYPE_U16);
    597     img2 = psImageCopy(img2,img,PS_TYPE_U32);
    598     img2 = psImageCopy(img2,img,PS_TYPE_S8);
    599     img2 = psImageCopy(img2,img,PS_TYPE_S16);
    600     img2 = psImageCopy(img2,img,PS_TYPE_S32);
    601     img2 = psImageCopy(img2,img,PS_TYPE_F64);
    602     img2 = psImageCopy(img2,img,PS_TYPE_C32);
    603     img2 = psImageCopy(img2,img,PS_TYPE_C64);
    604 
    605610    psImageFree(img);
    606611    psImageFree(img2);
Note: See TracChangeset for help on using the changeset viewer.