IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 2:57:34 PM (22 years ago)
Author:
desonia
Message:

converted native C types to ps Types, where practical.

File:
1 edited

Legend:

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

    r2068 r2204  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-13 01:22:38 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-27 00:57:33 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020#include "psType.h"
    2121
    22 static int testKernelAlloc(void);
    23 static int testKernelGenerate(void);
    24 //static int testImageConvolve(void);
     22static psS32 testKernelAlloc(void);
     23static psS32 testKernelGenerate(void);
     24//static psS32 testImageConvolve(void);
    2525
    2626testDescription tests[] = {
     
    3131                          };
    3232
    33 int main(int argc, char* argv[])
     33psS32 main(psS32 argc, char* argv[])
    3434{
    3535    psLogSetLevel(PS_LOG_INFO);
     
    3838}
    3939
    40 static int testKernelAlloc(void)
     40static psS32 testKernelAlloc(void)
    4141{
    42     int numCases = 4;
    43     int xMin[] = { -5,  0,-10,  5};
    44     int xMax[] = {  0,  5, -5, 10};
    45     int yMin[] = { -4,  0, -8,  4};
    46     int yMax[] = {  0,  4, -4,  8};
    47     int i;
     42    psS32 numCases = 4;
     43    psS32 xMin[] = { -5,  0,-10,  5};
     44    psS32 xMax[] = {  0,  5, -5, 10};
     45    psS32 yMin[] = { -4,  0, -8,  4};
     46    psS32 yMax[] = {  0,  4, -4,  8};
     47    psS32 i;
    4848    psKernel* k;
    4949
     
    7373        }
    7474
    75         for (int j=yMin[i]; j<yMax[i]; j++) {
     75        for (psS32 j=yMin[i]; j<yMax[i]; j++) {
    7676            if (k->kernel[j]+xMin[i] != k->image->data.PS_TYPE_KERNEL_DATA[j-yMin[i]]) {
    7777                psError(__func__,"The kernel pointer was set wrong for row %d.",
     
    115115}
    116116
    117 static int testKernelGenerate(void)
     117static psS32 testKernelGenerate(void)
    118118{
    119     int size = 4;
    120     int t[] = { 1, 2, 8, 10 };
    121     int x[] = { 0, 1, 0, -1 };
    122     int y[] = { 2, 1, -1, -2 };
     119    psS32 size = 4;
     120    psS32 t[] = { 1, 2, 8, 10 };
     121    psS32 x[] = { 0, 1, 0, -1 };
     122    psS32 y[] = { 2, 1, -1, -2 };
    123123    psKernelType sum;
    124124
     
    127127    psVector* tVec = psVectorAlloc(size,PS_TYPE_U32);
    128128
    129     for (int i = 0; i < size; i++) {
     129    for (psS32 i = 0; i < size; i++) {
    130130        xVec->data.U32[i] = x[i];
    131131        yVec->data.U32[i] = y[i];
     
    148148
    149149    sum = 0.0;
    150     for (int y = result->yMin; y <= result->yMax; y++) {
    151         for (int x = result->xMin; x <= result->xMax; x++) {
     150    for (psS32 y = result->yMin; y <= result->yMax; y++) {
     151        for (psS32 x = result->xMin; x <= result->xMax; x++) {
    152152            sum += result->kernel[y][x];
    153153        }
     
    182182    tVec = psVectorAlloc(size,PS_TYPE_S16);
    183183
    184     for (int i = 0; i < size; i++) {
     184    for (psS32 i = 0; i < size; i++) {
    185185        xVec->data.S16[i] = x[i];
    186186        yVec->data.S16[i] = y[i];
     
    203203
    204204    sum = 0.0;
    205     for (int y = result->yMin; y <= result->yMax; y++) {
    206         for (int x = result->xMin; x <= result->xMax; x++) {
     205    for (psS32 y = result->yMin; y <= result->yMax; y++) {
     206        for (psS32 x = result->xMin; x <= result->xMax; x++) {
    207207            sum += result->kernel[y][x];
    208208        }
     
    236236    tVec = psVectorAlloc(size,PS_TYPE_F32);
    237237
    238     for (int i = 0; i < size; i++) {
     238    for (psS32 i = 0; i < size; i++) {
    239239        xVec->data.F32[i] = x[i]+0.1;
    240240        yVec->data.F32[i] = y[i]+0.2;
     
    291291
    292292/*
    293 static int testImageConvolve(void)
     293static psS32 testImageConvolve(void)
    294294{
    295     const int r = 200;
    296     const int c = 300;
    297     int sum;
     295    const psS32 r = 200;
     296    const psS32 c = 300;
     297    psS32 sum;
    298298 
    299299    // approximate a normalized gaussian kernel.
     
    312312    psKernel* nsk = psKernelAlloc(0,2,0,2);
    313313    sum = 0.0;
    314     for (int i=0;i<2;i++) {
    315         for (int j=0;j<2;j++) {
     314    for (psS32 i=0;i<2;i++) {
     315        for (psS32 j=0;j<2;j++) {
    316316            nsk->kernel[i][j] = i+j;
    317317            sum = i+j;
    318318        }
    319319    }
    320     for (int i=0;i<2;i++) {
    321         for (int j=0;j<2;j++) {
     320    for (psS32 i=0;i<2;i++) {
     321        for (psS32 j=0;j<2;j++) {
    322322            nsk->kernel[i][j] /= sum;
    323323        }
     
    356356 
    357357    // test values
    358     for (int i=-1;i<1;i++) {
    359         for (int j=-1;j<1;j++) {
     358    for (psS32 i=-1;i<1;i++) {
     359        for (psS32 j=-1;j<1;j++) {
    360360            if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
    361361                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
     
    423423    psImageWriteSection(out2,0,0,0,NULL,0,"out2.fits");
    424424    // test values
    425     for (int i=-1;i<1;i++) {
    426         for (int j=-1;j<1;j++) {
     425    for (psS32 i=-1;i<1;i++) {
     426        for (psS32 j=-1;j<1;j++) {
    427427            if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
    428428                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
Note: See TracChangeset for help on using the changeset viewer.