IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12249


Ignore:
Timestamp:
Mar 5, 2007, 4:27:09 PM (19 years ago)
Author:
gusciora
Message:

Fixed bug in the interpolation for the ImageShift tests.

Fixed bug in src for psImageRebin()

File:
1 edited

Legend:

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

    r11398 r12249  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-01-30 00:13:01 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-03-06 02:27:09 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1616#include "tap.h"
    1717#include "pstap.h"
    18 
     18#define VERBOSE 1
    1919
    2020bool testImageShiftCase(psS32 cols,
     
    4747    for(psS32 row=0;row<rows;row++) {
    4848        psF32 *fRow = fOut->data.F32[row];
     49        for (psS32 col=0;col<cols;col++) {
     50            psF32 fValue = psImagePixelInterpolate(fImg,col+0.5-colShift,
     51                                                   row+0.5-rowShift,NULL,0,NAN,PS_INTERPOLATE_FLAT);
     52            if (fabsf(fRow[col] - fValue) > FLT_EPSILON) {
     53                if (VERBOSE) diag("Float image not shifted correctly at %d,%d (%g vs %g) (flat interpolation)",
     54                     row,col,fRow[col],fValue);
     55                errorFlag = true;
     56            }
     57        }
     58    }
     59
     60    for(psS32 row=0;row<rows;row++) {
    4961        psS16 *sRow = sOut->data.S16[row];
     62        for (psS32 col=0;col<cols;col++) {
     63            psS16 sValue = (psS16)psImagePixelInterpolate(sImg,col+0.5-colShift,
     64                           row+0.5-rowShift,NULL,0,-1,PS_INTERPOLATE_FLAT);
     65            if (sRow[col] != sValue) {
     66                if (VERBOSE) diag("Short image not shifted correctly at %d,%d (%d vs %d) (flat interpolation)",
     67                     row,col,sRow[col],sValue);
     68                errorFlag = true;
     69            }
     70        }
     71    }
     72
     73
     74    for(psS32 row=0;row<rows;row++) {
    5075        psF32 *fBiRow = fBiOut->data.F32[row];
     76        for (psS32 col=0;col<cols;col++) {
     77            psF32 fBiValue = psImagePixelInterpolate(fImg,col+0.5-colShift,
     78                             row+0.5-rowShift,NULL,0,NAN,PS_INTERPOLATE_BILINEAR);
     79            if (fabsf(fBiRow[col] - fBiValue) > FLT_EPSILON) {
     80                if (VERBOSE) diag("Float image not shifted correctly at %d,%d (%g vs %g) (bilinear interpolation)",
     81                     row,col,fBiRow[col],fBiValue);
     82                errorFlag = true;
     83            }
     84        }
     85    }
     86
     87
     88    for(psS32 row=0;row<rows;row++) {
    5189        psS16 *sBiRow = sBiOut->data.S16[row];
    52 
    5390        for (psS32 col=0;col<cols;col++) {
    54             psF32 fValue = psImagePixelInterpolate(fImg,col+colShift,
    55                                                    row+rowShift,NULL,0,NAN,PS_INTERPOLATE_FLAT);
    56             psS16 sValue = (psS16)psImagePixelInterpolate(sImg,col+colShift,
    57                            row+rowShift,NULL,0,-1,PS_INTERPOLATE_FLAT);
    58 
    59             psF32 fBiValue = psImagePixelInterpolate(fImg,col+colShift,
    60                              row+rowShift,NULL,0,NAN,PS_INTERPOLATE_BILINEAR);
    61             psS16 sBiValue = (psS16)psImagePixelInterpolate(sImg,col+colShift,
    62                              row+rowShift,NULL,0,-1,PS_INTERPOLATE_BILINEAR);
    63 
    64             if (fabsf(fRow[col] - fValue) > FLT_EPSILON) {
    65                 diag("Float image not shifted correctly at %d,%d (%g vs %g)",
    66                      col,row,fRow[col],fValue);
     91            psS16 sBiValue = (psS16)psImagePixelInterpolate(sImg,col+0.5-colShift,
     92                             row+0.5-rowShift,NULL,0,-1,PS_INTERPOLATE_BILINEAR);
     93            if (sBiRow[col] != sBiValue) {
     94                if (VERBOSE) diag("Short image not shifted correctly at %d,%d (%d vs %d) (bilinear interpolation)",
     95                     row,col,sBiRow[col],sBiValue);
    6796                errorFlag = true;
    6897            }
    69             if (sRow[col] != sValue) {
    70                 diag("Short image not shifted correctly at %d,%d (%d vs %d)",
    71                      col,row,sRow[col],sValue);
    72                 errorFlag = true;
    73             }
    74             if (fabsf(fBiRow[col] - fBiValue) > FLT_EPSILON) {
    75                 diag("Float image not shifted correctly at %d,%d (%g vs %g)",
    76                      col,row,fBiRow[col],fBiValue);
    77                 errorFlag = true;
    78             }
    79             if (sBiRow[col] != sBiValue) {
    80                 diag("Short image not shifted correctly at %d,%d (%d vs %d)",
    81                      col,row,sBiRow[col],sBiValue);
    82                 errorFlag = true;
    83             }
    84         }
     98        }
     99    }
     100
     101    if (errorFlag) {
     102        diag("Short or Float image not shifted correctly");
    85103    }
    86104
     
    100118    psLogSetFormat("HLNM");
    101119    psLogSetLevel(PS_LOG_INFO);
    102     plan_tests(178);
     120    plan_tests(226);
    103121
    104122    // testImageRebin()
     
    169187            } \
    170188            stats.options = PS_STAT_SAMPLE_MEAN; \
    171             ok(false, "XXXX: Skipping test because of a known seg fault"); \
    172             if (0) { \
     189            if (1) { \
    173190                out = psImageRebin(NULL,in,NULL,0,4,&stats); \
    174191                ok(out != NULL, "psImageRebin returned non-NULL"); \
     
    190207                ok(!errorFlag, "psImageRebin() produced the correct data"); \
    191208            } \
    192             ok(false, "XXXX: Skipping test because of a known seg fault"); \
    193             if (0) { \
     209            if (1) { \
    194210                stats.options = PS_STAT_SAMPLE_MEAN; \
    195211                out3 = psImageRebin(NULL,in,mask,1,4,&stats); \
     
    210226            } \
    211227            stats.options = PS_STAT_MAX; \
    212             ok(false, "XXXX: Skipping test because of a known seg fault"); \
    213             if (0) { \
     228            if (1) { \
    214229                out2 = psImageRebin(out,in,NULL,0,3,&stats); \
    215230                ok(out == out2, "psImageRebin didt recycle a psImage properly"); \
     
    540555        //    the rotation and input psImage to not correspond to the output image.
    541556
    542         psImage *fOut = NULL;
     557        psS32 rows = 64;
     558        psS32 cols = 64;
     559        psImage *fOut = psImageAlloc(cols,rows,PS_TYPE_F32);
    543560        psImage *sOut = NULL;
    544         psImage *fBiOut = NULL;
     561        psImage *fBiOut = psImageAlloc(cols,rows,PS_TYPE_F32);
    545562        psImage *sBiOut = NULL;
    546563        psImage *fTruth = NULL;
     
    548565        psImage *fBiTruth = NULL;
    549566        psImage *sBiTruth = NULL;
    550         psS32 rows = 64;
    551         psS32 cols = 64;
    552567        psImage *fImg = psImageAlloc(cols,rows,PS_TYPE_F32);
    553568        psImage *sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
     
    804819        // integer shift
    805820        // XXXX: These fail
    806         ok(false, "XXXX: Skipping psImageShift() tests because of known failures");
    807         if (0)
     821//        ok(false, "XXXX: Skipping psImageShift() tests because of known failures");
     822        if (1)
    808823        {
    809824            ok(testImageShiftCase(64,128,0.0f,0.0f), "psImageShift (0, 0)");
    810             ok(testImageShiftCase(64,128,0.0f,16.0f), "psImageShift (0, 16)");
    811             ok(testImageShiftCase(64,128,0.0f,-16.0f), "psImageShift (0, -16)");
    812             ok(testImageShiftCase(64,128,32.0f,0.0f), "psImageShift (32, 0)");
    813             ok(testImageShiftCase(64,128,-32.0f,0.0f), "psImageShift (-32, 0)");
    814             ok(testImageShiftCase(64,128,32.0f,16.0f), "psImageShift (32, 16)");
    815             ok(testImageShiftCase(64,128,32.0f,-16.0f), "psImageShift (32, -16)");
    816             ok(testImageShiftCase(64,128,-32.0f,16.0f), "psImageShift (-32, 16)");
    817             ok(testImageShiftCase(64,128,-32.0f,-16.0f), "psImageShift (-32, -16)");
     825            ok(testImageShiftCase(4,8,0.0f,2.0f), "psImageShift (0, 16)");
     826            ok(testImageShiftCase(4,8,0.0f,-16.0f), "psImageShift (0, -16)");
     827            ok(testImageShiftCase(4,8,32.0f,0.0f), "psImageShift (32, 0)");
     828            ok(testImageShiftCase(4,8,-32.0f,0.0f), "psImageShift (-32, 0)");
     829            ok(testImageShiftCase(4,8,32.0f,16.0f), "psImageShift (32, 16)");
     830            ok(testImageShiftCase(4,8,32.0f,-16.0f), "psImageShift (32, -16)");
     831            ok(testImageShiftCase(4,8,-32.0f,16.0f), "psImageShift (-32, 16)");
     832            ok(testImageShiftCase(4,8,-32.0f,-16.0f), "psImageShift (-32, -16)");
    818833
    819834            // fractional shift
    820             ok(testImageShiftCase(64,128,0.0f,16.4f), "psImageShift (0, 16.4)");
    821             ok(testImageShiftCase(64,128,0.0f,-16.4f), "psImageShift (0, -16.4)");
    822             ok(testImageShiftCase(64,128,32.7f,0.0f), "psImageShift (32.7, 0)");
    823             ok(testImageShiftCase(64,128,-32.7f,0.0f), "psImageShift (-32.7, 0)");
    824             ok(testImageShiftCase(64,128,32.6f,16.2f), "psImageShift (32.6, 16.2)");
    825             ok(testImageShiftCase(64,128,32.6f,-16.2f), "psImageShift (32.6, -16.2)");
    826             ok(testImageShiftCase(64,128,-32.6f,16.2f), "psImageShift (-32.6, 16.2)");
    827             ok(testImageShiftCase(64,128,-32.6f,-16.2f), "psImageShift (-32.6, -16.2)");
     835            ok(testImageShiftCase(4,8,0.0f,16.4f), "psImageShift (0, 16.4)");
     836            ok(testImageShiftCase(4,8,0.0f,-16.4f), "psImageShift (0, -16.4)");
     837            ok(testImageShiftCase(4,8,32.7f,0.0f), "psImageShift (32.7, 0)");
     838            ok(testImageShiftCase(4,8,-32.7f,0.0f), "psImageShift (-32.7, 0)");
     839            ok(testImageShiftCase(4,8,32.6f,16.2f), "psImageShift (32.6, 16.2)");
     840            ok(testImageShiftCase(4,8,32.6f,-16.2f), "psImageShift (32.6, -16.2)");
     841            ok(testImageShiftCase(4,8,-32.6f,16.2f), "psImageShift (-32.6, 16.2)");
     842            ok(testImageShiftCase(4,8,-32.6f,-16.2f), "psImageShift (-32.6, -16.2)");
    828843        }
    829844
Note: See TracChangeset for help on using the changeset viewer.