Changeset 1406 for trunk/psLib/test/image
- Timestamp:
- Aug 6, 2004, 12:34:06 PM (22 years ago)
- Location:
- trunk/psLib/test/image
- Files:
-
- 8 edited
-
tst_psImage.c (modified) (3 diffs)
-
tst_psImageExtraction.c (modified) (1 diff)
-
tst_psImageFFT.c (modified) (3 diffs)
-
tst_psImageIO.c (modified) (3 diffs)
-
tst_psImageManip.c (modified) (3 diffs)
-
tst_psImageStats00.c (modified) (3 diffs)
-
tst_psImageStats01.c (modified) (2 diffs)
-
tst_psImageStats02.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImage.c
r1212 r1406 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 7-13 01:37:58$8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-08-06 22:34:06 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 27 27 testDescription tests[] = { 28 {testImageAlloc,546,"psImageAlloc",0,false}, 29 {testImageAlloc,548,"psImageFree",0,true}, 30 {testImageSubset,547,"psImageSubset",0,false}, 31 {testImageSubset,550,"psImageSubset",0,true}, 32 {testImageCopy,551,"psImageCopy",0,false}, 33 {NULL} 28 { 29 testImageAlloc,546,"psImageAlloc",0,false 30 }, 31 { 32 testImageAlloc,548,"psImageFree",0,true 33 }, 34 { 35 testImageSubset,547,"psImageSubset",0,false 36 }, 37 { 38 testImageSubset,550,"psImageSubset",0,true 39 }, 40 { 41 testImageCopy,551,"psImageCopy",0,false 42 }, 43 { 44 NULL 45 } 34 46 }; 35 47 … … 49 61 psImage* image = NULL; 50 62 unsigned int sizes = 6; 51 unsigned int numCols[] = {0,1,1,100,100,150}; 52 unsigned int numRows[] = {0,1,100,1,150,100}; 63 unsigned int numCols[] = { 64 0,1,1,100,100,150 65 }; 66 unsigned int numRows[] = { 67 0,1,100,1,150,100 68 }; 53 69 unsigned int types = 12; 54 70 psElemType type[] = { PS_TYPE_S8, PS_TYPE_S16, PS_TYPE_S32, PS_TYPE_S64, -
trunk/psLib/test/image/tst_psImageExtraction.c
r1405 r1406 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-08-06 22: 29:11$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-08-06 22:34:06 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii -
trunk/psLib/test/image/tst_psImageFFT.c
r1193 r1406 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 7-08 01:05:01$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-08-06 22:34:06 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 35 35 testDescription tests[] = { 36 {testImageFFT,600,"psImageFFT",0,false}, 37 {testImageRealImaginary,601,"psImageRealImaginary",0,false}, 38 {testImageComplex,602,"psImageComplex",0,false}, 39 {testImageConjugate,603,"psImageConjugate",0,false}, 40 {testImagePowerSpectrum,604,"psImagePowerSpectrum",0,false}, 41 {NULL} 36 { 37 testImageFFT,600,"psImageFFT",0,false 38 }, 39 { 40 testImageRealImaginary,601,"psImageRealImaginary",0,false 41 }, 42 { 43 testImageComplex,602,"psImageComplex",0,false 44 }, 45 { 46 testImageConjugate,603,"psImageConjugate",0,false 47 }, 48 { 49 testImagePowerSpectrum,604,"psImagePowerSpectrum",0,false 50 }, 51 { 52 NULL 53 } 42 54 }; 43 55 … … 89 101 psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag); 90 102 } 91 } else if ( (col == 0 && (row == 1 || row == n-1)) 103 } else 104 if ( (col == 0 && (row == 1 || row == n-1)) 92 105 || (row == 0 && (col==1 || col == n-1)) ) { 93 psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag);94 }106 psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag); 107 } 95 108 } 96 109 } -
trunk/psLib/test/image/tst_psImageIO.c
r1253 r1406 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 7-21 23:49:52$8 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-08-06 22:34:06 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 36 36 testDescription tests[] = { 37 {testImageRead,567,"psImageReadSection",0,false}, 38 {testImageWrite,569,"psImageWriteSection",0,false}, 39 {NULL} 37 { 38 testImageRead,567,"psImageReadSection",0,false 39 }, 40 { 41 testImageWrite,569,"psImageWriteSection",0,false 42 }, 43 { 44 NULL 45 } 40 46 }; 41 47 … … 291 297 mkdir("tmpImages",0777); 292 298 remove 293 ("writeTest.fits"); 299 ("writeTest.fits") 300 ; 294 301 if (! psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeTest.fits")) { 295 302 psError(__func__,"Couldn't write writeTest.fits."); -
trunk/psLib/test/image/tst_psImageManip.c
r1319 r1406 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 7-29 01:20:10$8 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-08-06 22:34:06 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 33 33 34 34 testDescription tests[] = { 35 {testImageClip,571,"psImageClip",0,false}, 36 {testImageClipNAN,572,"psImageClipNAN",0,false}, 37 {testImageClipComplexRegion,673,"psImageClipComplexRegion",0,false}, 38 {testImageOverlay,573,"psImageOverlay",0,false}, 39 {testImageRebin,559,"psImageRebin",0,false}, 40 {testImageRoll,562,"psImageRoll",0,false}, 41 {testImageRotate,560,"psImageRotate",0,false}, 42 {NULL} 35 { 36 testImageClip,571,"psImageClip",0,false 37 }, 38 { 39 testImageClipNAN,572,"psImageClipNAN",0,false 40 }, 41 { 42 testImageClipComplexRegion,673,"psImageClipComplexRegion",0,false 43 }, 44 { 45 testImageOverlay,573,"psImageOverlay",0,false 46 }, 47 { 48 testImageRebin,559,"psImageRebin",0,false 49 }, 50 { 51 testImageRoll,562,"psImageRoll",0,false 52 }, 53 { 54 testImageRotate,560,"psImageRotate",0,false 55 }, 56 { 57 NULL 58 } 43 59 }; 44 60 … … 1117 1133 mkdir("temp",0777); 1118 1134 remove 1119 ("temp/fOut.fits"); 1135 ("temp/fOut.fits") 1136 ; 1120 1137 remove 1121 ("temp/sOut.fits"); 1138 ("temp/sOut.fits") 1139 ; 1122 1140 int index = 0; 1123 1141 bool fail = false; -
trunk/psLib/test/image/tst_psImageStats00.c
r1365 r1406 28 28 int IMAGE_Y_SIZE = 0; 29 29 int currentId = 0; 30 30 31 31 currentId = psMemGetId(); 32 32 for ( nb = 0;nb < 6;nb++ ) { 33 if ( nb == 0 ) { 34 IMAGE_X_SIZE = 1; 35 IMAGE_Y_SIZE = 1; 33 if ( nb == 0 ) { 34 IMAGE_X_SIZE = 1; 35 IMAGE_Y_SIZE = 1; 36 } 37 if ( nb == 1 ) { 38 IMAGE_X_SIZE = 1; 39 IMAGE_Y_SIZE = N; 40 } 41 if ( nb == 2 ) { 42 IMAGE_X_SIZE = N; 43 IMAGE_Y_SIZE = 1; 44 } 45 if ( nb == 3 ) { 46 IMAGE_X_SIZE = N; 47 IMAGE_Y_SIZE = N; 48 } 49 if ( nb == 4 ) { 50 IMAGE_X_SIZE = N; 51 IMAGE_Y_SIZE = M; 52 } 53 if ( nb == 5 ) { 54 IMAGE_X_SIZE = M; 55 IMAGE_Y_SIZE = N; 56 } 57 printf( "*******************************\n" ); 58 printf( "* IMAGE SIZE is (%d by %d)\n", IMAGE_X_SIZE, IMAGE_Y_SIZE ); 59 printf( "*******************************\n" ); 60 /*********************************************************************/ 61 /* Allocate and initialize data structures */ 62 /*********************************************************************/ 63 tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 ); 64 65 for ( i = 0;i < tmpImage->numRows;i++ ) { 66 for ( j = 0;j < tmpImage->numCols;j++ ) { 67 tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j + 0.1 ); 68 } 69 } 70 tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 ); 71 for ( i = 0;i < tmpMask->numRows;i++ ) { 72 for ( j = 0;j < tmpMask->numCols;j++ ) { 73 if ( ( i > ( tmpMask->numRows / 2 ) ) && 74 ( j > ( tmpMask->numCols / 2 ) ) ) { 75 tmpMask->data.U8[ i ][ j ] = 1; 76 } else { 77 tmpMask->data.U8[ i ][ j ] = 0; 36 78 } 37 if ( nb == 1 ) { 38 IMAGE_X_SIZE = 1; 39 IMAGE_Y_SIZE = N; 40 } 41 if ( nb == 2 ) { 42 IMAGE_X_SIZE = N; 43 IMAGE_Y_SIZE = 1; 44 } 45 if ( nb == 3 ) { 46 IMAGE_X_SIZE = N; 47 IMAGE_Y_SIZE = N; 48 } 49 if ( nb == 4 ) { 50 IMAGE_X_SIZE = N; 51 IMAGE_Y_SIZE = M; 52 } 53 if ( nb == 5 ) { 54 IMAGE_X_SIZE = M; 55 IMAGE_Y_SIZE = N; 56 } 57 printf( "*******************************\n" ); 58 printf( "* IMAGE SIZE is (%d by %d)\n", IMAGE_X_SIZE, IMAGE_Y_SIZE ); 59 printf( "*******************************\n" ); 60 /*********************************************************************/ 61 /* Allocate and initialize data structures */ 62 /*********************************************************************/ 63 tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 ); 64 65 for ( i = 0;i < tmpImage->numRows;i++ ) { 66 for ( j = 0;j < tmpImage->numCols;j++ ) { 67 tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j + 0.1 ); 68 } 69 } 70 tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 ); 71 for ( i = 0;i < tmpMask->numRows;i++ ) { 72 for ( j = 0;j < tmpMask->numCols;j++ ) { 73 if ( ( i > ( tmpMask->numRows / 2 ) ) && 74 ( j > ( tmpMask->numCols / 2 ) ) ) { 75 tmpMask->data.U8[ i ][ j ] = 1; 76 } else { 77 tmpMask->data.U8[ i ][ j ] = 0; 78 } 79 } 80 } 81 82 /*************************************************************************/ 83 /* Calculate Histogram with no mask */ 84 /*************************************************************************/ 85 printPositiveTestHeader( stdout, 86 "psImageStats functions", 87 "Calculate Histogram, no mask" ); 88 89 myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ), 90 NUM_BINS ); 91 myHist = psImageHistogram( myHist, tmpImage, NULL, 0 ); 92 for ( i = 0;i < NUM_BINS;i++ ) { 93 printf( "Bin number %d bounds: (%.1f - %.1f) data (%d)\n", i, 94 myHist->bounds->data.F32[ i ], 95 myHist->bounds->data.F32[ i + 1 ], 96 myHist->nums->data.S32[ i ] ); 97 } 98 psFree( myHist ); 99 100 psMemCheckCorruption( 1 ); 101 printFooter( stdout, 102 "psImageStats functions", 103 "Calculate Histogram, no mask", 104 testStatus ); 105 106 /*************************************************************************/ 107 /* Calculate Histogram with mask */ 108 /*************************************************************************/ 109 printPositiveTestHeader( stdout, 110 "psImageStats functions", 111 "Calculate Histogram with mask" ); 112 113 myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ), 114 NUM_BINS ); 115 myHist = psImageHistogram( myHist, tmpImage, tmpMask, 1 ); 116 for ( i = 0;i < NUM_BINS;i++ ) { 117 printf( "Bin number %d bounds: (%.2f - %.2f) data (%d)\n", i, 118 myHist->bounds->data.F32[ i ], 119 myHist->bounds->data.F32[ i + 1 ], 120 myHist->nums->data.S32[ i ] ); 121 } 122 123 psMemCheckCorruption( 1 ); 124 printFooter( stdout, 125 "psImageStats functions", 126 "Calculate Histogram with mask", 127 testStatus ); 128 129 /*************************************************************************/ 130 /* Deallocate data structures */ 131 /*************************************************************************/ 132 printPositiveTestHeader( stdout, 133 "psImageStats functions", 134 "Deallocate the psHistogram/psImage structure." ); 135 psFree( myHist ); 136 psFree( tmpImage ); 137 psFree( tmpMask ); 138 139 psMemCheckCorruption( 1 ); 140 memLeaks = psMemCheckLeaks( currentId, NULL, NULL ); 141 if ( 0 != memLeaks ) { 142 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks ); 143 } 144 145 printFooter( stdout, 146 "psImageStats functions", 147 "Deallocate the psHistogram/psImage structure.", 148 testStatus ); 79 } 149 80 } 81 82 /*************************************************************************/ 83 /* Calculate Histogram with no mask */ 84 /*************************************************************************/ 85 printPositiveTestHeader( stdout, 86 "psImageStats functions", 87 "Calculate Histogram, no mask" ); 88 89 myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ), 90 NUM_BINS ); 91 myHist = psImageHistogram( myHist, tmpImage, NULL, 0 ); 92 for ( i = 0;i < NUM_BINS;i++ ) { 93 printf( "Bin number %d bounds: (%.1f - %.1f) data (%d)\n", i, 94 myHist->bounds->data.F32[ i ], 95 myHist->bounds->data.F32[ i + 1 ], 96 myHist->nums->data.S32[ i ] ); 97 } 98 psFree( myHist ); 99 100 psMemCheckCorruption( 1 ); 101 printFooter( stdout, 102 "psImageStats functions", 103 "Calculate Histogram, no mask", 104 testStatus ); 105 106 /*************************************************************************/ 107 /* Calculate Histogram with mask */ 108 /*************************************************************************/ 109 printPositiveTestHeader( stdout, 110 "psImageStats functions", 111 "Calculate Histogram with mask" ); 112 113 myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ), 114 NUM_BINS ); 115 myHist = psImageHistogram( myHist, tmpImage, tmpMask, 1 ); 116 for ( i = 0;i < NUM_BINS;i++ ) { 117 printf( "Bin number %d bounds: (%.2f - %.2f) data (%d)\n", i, 118 myHist->bounds->data.F32[ i ], 119 myHist->bounds->data.F32[ i + 1 ], 120 myHist->nums->data.S32[ i ] ); 121 } 122 123 psMemCheckCorruption( 1 ); 124 printFooter( stdout, 125 "psImageStats functions", 126 "Calculate Histogram with mask", 127 testStatus ); 128 129 /*************************************************************************/ 130 /* Deallocate data structures */ 131 /*************************************************************************/ 132 printPositiveTestHeader( stdout, 133 "psImageStats functions", 134 "Deallocate the psHistogram/psImage structure." ); 135 psFree( myHist ); 136 psFree( tmpImage ); 137 psFree( tmpMask ); 138 139 psMemCheckCorruption( 1 ); 140 memLeaks = psMemCheckLeaks( currentId, NULL, NULL ); 141 if ( 0 != memLeaks ) { 142 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks ); 143 } 144 145 printFooter( stdout, 146 "psImageStats functions", 147 "Deallocate the psHistogram/psImage structure.", 148 testStatus ); 149 } 150 150 printPositiveTestHeader( stdout, 151 151 "psImageStats functions", 152 152 "Calling psImageHistogram() with NULL parameters" ); 153 153 154 154 tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 ); 155 155 myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ), … … 157 157 myHist2 = psImageHistogram( NULL, tmpImage, NULL, 0 ); 158 158 if ( myHist2 != NULL ) { 159 printf( "ERROR: myHist2 not equal to NULL\n" );160 }161 159 printf( "ERROR: myHist2 not equal to NULL\n" ); 160 } 161 162 162 myHist2 = psImageHistogram( myHist, NULL, NULL, 0 ); 163 163 myHist2 = psImageHistogram( NULL, tmpImage, NULL, 0 ); 164 164 if ( myHist2 != NULL ) { 165 printf( "ERROR: myHist2 not equal to NULL\n" );166 }167 165 printf( "ERROR: myHist2 not equal to NULL\n" ); 166 } 167 168 168 psMemCheckCorruption( 1 ); 169 169 psFree( myHist ); … … 172 172 memLeaks = psMemCheckLeaks( currentId, NULL, NULL ); 173 173 if ( 0 != memLeaks ) { 174 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );175 }176 174 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks ); 175 } 176 177 177 printFooter( stdout, 178 178 "psImageStats functions", 179 179 "Calling psImageHistogram() with NULL parameters", 180 180 testStatus ); 181 181 182 182 return ( !testStatus ); 183 183 } -
trunk/psLib/test/image/tst_psImageStats01.c
r1365 r1406 29 29 int IMAGE_Y_SIZE = 0; 30 30 int currentId = 0; 31 31 32 32 currentId = psMemGetId(); 33 33 for ( nb = 0;nb < 6;nb++ ) { 34 if ( nb == 0 ) { 35 IMAGE_X_SIZE = 1; 36 IMAGE_Y_SIZE = 1; 34 if ( nb == 0 ) { 35 IMAGE_X_SIZE = 1; 36 IMAGE_Y_SIZE = 1; 37 } 38 if ( nb == 1 ) { 39 IMAGE_X_SIZE = 1; 40 IMAGE_Y_SIZE = N; 41 } 42 if ( nb == 2 ) { 43 IMAGE_X_SIZE = N; 44 IMAGE_Y_SIZE = 1; 45 } 46 if ( nb == 3 ) { 47 IMAGE_X_SIZE = N; 48 IMAGE_Y_SIZE = N; 49 } 50 if ( nb == 4 ) { 51 IMAGE_X_SIZE = N; 52 IMAGE_Y_SIZE = M; 53 } 54 if ( nb == 5 ) { 55 IMAGE_X_SIZE = M; 56 IMAGE_Y_SIZE = N; 57 } 58 printf( "*******************************\n" ); 59 printf( "* IMAGE SIZE is (%d by %d)\n", IMAGE_X_SIZE, IMAGE_Y_SIZE ); 60 printf( "*******************************\n" ); 61 62 /*************************************************************************/ 63 /* Allocate and initialize data structures */ 64 /*************************************************************************/ 65 tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 ); 66 67 for ( i = 0;i < tmpImage->numRows;i++ ) { 68 for ( j = 0;j < tmpImage->numCols;j++ ) { 69 tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ); 70 } 71 } 72 tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 ); 73 for ( i = 0;i < tmpMask->numRows;i++ ) { 74 for ( j = 0;j < tmpMask->numCols;j++ ) { 75 if ( ( i > ( tmpMask->numRows / 2 ) ) && 76 ( j > ( tmpMask->numCols / 2 ) ) ) { 77 tmpMask->data.U8[ i ][ j ] = 1; 78 } else { 79 tmpMask->data.U8[ i ][ j ] = 0; 37 80 } 38 if ( nb == 1 ) { 39 IMAGE_X_SIZE = 1; 40 IMAGE_Y_SIZE = N; 41 } 42 if ( nb == 2 ) { 43 IMAGE_X_SIZE = N; 44 IMAGE_Y_SIZE = 1; 45 } 46 if ( nb == 3 ) { 47 IMAGE_X_SIZE = N; 48 IMAGE_Y_SIZE = N; 49 } 50 if ( nb == 4 ) { 51 IMAGE_X_SIZE = N; 52 IMAGE_Y_SIZE = M; 53 } 54 if ( nb == 5 ) { 55 IMAGE_X_SIZE = M; 56 IMAGE_Y_SIZE = N; 57 } 58 printf( "*******************************\n" ); 59 printf( "* IMAGE SIZE is (%d by %d)\n", IMAGE_X_SIZE, IMAGE_Y_SIZE ); 60 printf( "*******************************\n" ); 61 62 /*************************************************************************/ 63 /* Allocate and initialize data structures */ 64 /*************************************************************************/ 65 tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 ); 66 67 for ( i = 0;i < tmpImage->numRows;i++ ) { 68 for ( j = 0;j < tmpImage->numCols;j++ ) { 69 tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ); 70 } 71 } 72 tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 ); 73 for ( i = 0;i < tmpMask->numRows;i++ ) { 74 for ( j = 0;j < tmpMask->numCols;j++ ) { 75 if ( ( i > ( tmpMask->numRows / 2 ) ) && 76 ( j > ( tmpMask->numCols / 2 ) ) ) { 77 tmpMask->data.U8[ i ][ j ] = 1; 78 } else { 79 tmpMask->data.U8[ i ][ j ] = 0; 80 } 81 } 82 } 83 84 myStats = psStatsAlloc( PS_STAT_SAMPLE_MEAN ); 85 /*************************************************************************/ 86 /* Calculate Sample Mean with no mask */ 87 /*************************************************************************/ 88 printPositiveTestHeader( stdout, 89 "psImageStats functions", 90 "Calculate Sample Mean, no mask %d" ); 91 92 myStats = psImageStats( myStats, tmpImage, NULL, 0 ); 93 printf( "The sample mean was %.2f\n", myStats->sampleMean ); 94 95 psMemCheckCorruption( 1 ); 96 97 printFooter( stdout, 98 "psImageStats functions", 99 "Calculate Sample Mean, no mask", 100 testStatus ); 101 102 /*************************************************************************/ 103 /* Calculate Sample Mean with mask */ 104 /*************************************************************************/ 105 printPositiveTestHeader( stdout, 106 "psImageStats functions", 107 "Calculate Sample Mean with mask" ); 108 109 myStats = psImageStats( myStats, tmpImage, tmpMask, 1 ); 110 printf( "The sample mean was %.2f\n", myStats->sampleMean ); 111 112 psMemCheckCorruption( 1 ); 113 114 printFooter( stdout, 115 "psImageStats functions", 116 "Calculate Sample Mean with mask", 117 testStatus ); 118 119 /*************************************************************************/ 120 /* Deallocate data structures */ 121 /*************************************************************************/ 122 printPositiveTestHeader( stdout, 123 "psImageStats functions", 124 "Deallocate the psStats/psImage structure." ); 125 psFree( myStats ); 126 psFree( tmpImage ); 127 psFree( tmpMask ); 128 129 psMemCheckCorruption( 1 ); 130 memLeaks = psMemCheckLeaks( currentId, NULL, NULL ); 131 if ( 0 != memLeaks ) { 132 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks ); 133 } 134 135 printFooter( stdout, 136 "psImageStats functions", 137 "Deallocate the psStats/psImage structure.", 138 testStatus ); 81 } 139 82 } 140 83 84 myStats = psStatsAlloc( PS_STAT_SAMPLE_MEAN ); 85 /*************************************************************************/ 86 /* Calculate Sample Mean with no mask */ 87 /*************************************************************************/ 88 printPositiveTestHeader( stdout, 89 "psImageStats functions", 90 "Calculate Sample Mean, no mask %d" ); 91 92 myStats = psImageStats( myStats, tmpImage, NULL, 0 ); 93 printf( "The sample mean was %.2f\n", myStats->sampleMean ); 94 95 psMemCheckCorruption( 1 ); 96 97 printFooter( stdout, 98 "psImageStats functions", 99 "Calculate Sample Mean, no mask", 100 testStatus ); 101 102 /*************************************************************************/ 103 /* Calculate Sample Mean with mask */ 104 /*************************************************************************/ 105 printPositiveTestHeader( stdout, 106 "psImageStats functions", 107 "Calculate Sample Mean with mask" ); 108 109 myStats = psImageStats( myStats, tmpImage, tmpMask, 1 ); 110 printf( "The sample mean was %.2f\n", myStats->sampleMean ); 111 112 psMemCheckCorruption( 1 ); 113 114 printFooter( stdout, 115 "psImageStats functions", 116 "Calculate Sample Mean with mask", 117 testStatus ); 118 119 /*************************************************************************/ 120 /* Deallocate data structures */ 121 /*************************************************************************/ 122 printPositiveTestHeader( stdout, 123 "psImageStats functions", 124 "Deallocate the psStats/psImage structure." ); 125 psFree( myStats ); 126 psFree( tmpImage ); 127 psFree( tmpMask ); 128 129 psMemCheckCorruption( 1 ); 130 memLeaks = psMemCheckLeaks( currentId, NULL, NULL ); 131 if ( 0 != memLeaks ) { 132 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks ); 133 } 134 135 printFooter( stdout, 136 "psImageStats functions", 137 "Deallocate the psStats/psImage structure.", 138 testStatus ); 139 } 140 141 141 /*************************************************************************/ 142 142 /* Test With Various Null Inputs */ … … 145 145 "psImageStats functions", 146 146 "Test With Various Null Inputs" ); 147 147 148 148 tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 ); 149 149 tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 ); 150 150 myStats = psStatsAlloc( 0 ); 151 151 152 152 myStats2 = psImageStats( myStats, NULL, NULL, 0 ); 153 153 if ( myStats2 != NULL ) { 154 printf( "ERROR: myStats2 = psImageStats(myStats, NULL, NULL, 0) != NULL\n" );155 }156 154 printf( "ERROR: myStats2 = psImageStats(myStats, NULL, NULL, 0) != NULL\n" ); 155 } 156 157 157 myStats2 = psImageStats( NULL, tmpImage, NULL, 0 ); 158 158 if ( myStats2 != NULL ) { 159 printf( "ERROR: myStats2 = psImageStats(NULL, tmpImage, NULL, 0) != NULL\n" );160 }161 159 printf( "ERROR: myStats2 = psImageStats(NULL, tmpImage, NULL, 0) != NULL\n" ); 160 } 161 162 162 myStats2 = psImageStats( myStats, tmpImage, NULL, 0 ); 163 163 164 164 psFree( myStats ); 165 165 psFree( tmpImage ); 166 166 psFree( tmpMask ); 167 167 168 168 psMemCheckCorruption( 1 ); 169 169 memLeaks = psMemCheckLeaks( currentId, NULL, NULL ); 170 170 if ( 0 != memLeaks ) { 171 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );172 }173 171 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks ); 172 } 173 174 174 printFooter( stdout, 175 175 "psImageStats functions", -
trunk/psLib/test/image/tst_psImageStats02.c
r1365 r1406 4 4 thouroughly tested elsewhere, we will only test psImageStats() with 5 5 the PS_STAT_SAMPLE_MEAN here. 6 6 7 7 NOTE: After you debug, set CHEBY_X_DIM != CHEBY_Y_DIM. 8 8 Also, uses non-square images. … … 32 32 int rc = 0; 33 33 int currentId = 0; 34 34 35 35 currentId = psMemGetId(); 36 36 /*************************************************************************/ … … 40 40 outImage = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32 ); 41 41 for ( i = 0;i < IMAGE_SIZE;i++ ) { 42 for ( j = 0;j < IMAGE_SIZE;j++ ) { 43 tmpImage->data.F32[ i ][ j ] = 4.0; 44 tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ); 45 tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i ); 46 outImage->data.F32[ i ][ j ] = 0.0; 47 } 42 for ( j = 0;j < IMAGE_SIZE;j++ ) { 43 tmpImage->data.F32[ i ][ j ] = 4.0; 44 tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ); 45 tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i ); 46 outImage->data.F32[ i ][ j ] = 0.0; 48 47 } 48 } 49 49 my2DPoly = psPolynomial2DAlloc( CHEBY_X_DIM, CHEBY_Y_DIM ); 50 50 /*************************************************************************/ … … 54 54 "psImageStats functions", 55 55 "Calculate Chebyshev Polynomials, no mask" ); 56 56 57 57 my2DPoly = psImageFitPolynomial( tmpImage, my2DPoly ); 58 58 for ( i = 0;i < CHEBY_X_DIM;i++ ) { 59 for ( j = 0;j < CHEBY_Y_DIM;j++ ) { 60 printf( "Cheby Polynomial (%d, %d) coefficient is %.2f\n", i, j, my2DPoly->coeff[ i ][ j ] ); 61 } 59 for ( j = 0;j < CHEBY_Y_DIM;j++ ) { 60 printf( "Cheby Polynomial (%d, %d) coefficient is %.2f\n", i, j, my2DPoly->coeff[ i ][ j ] ); 62 61 } 63 62 } 63 64 64 psMemCheckCorruption( 1 ); 65 65 printFooter( stdout, … … 73 73 "psImageStats functions", 74 74 "Calculate Chebyshev Polynomials, no mask" ); 75 75 76 76 rc = psImageEvalPolynomial( outImage, my2DPoly ); 77 77 for ( i = 0;i < IMAGE_SIZE;i++ ) { 78 for ( j = 0;j < IMAGE_SIZE;j++ ) { 79 80 // printf("pixel[%d][%d] is (%f, %f)\n", i, j, 81 // tmpImage->data.F32[i][j], 82 // outImage->data.F32[i][j]); 83 if ( fabs( outImage->data.F32[ i ][ j ] - tmpImage->data.F32[ i ][ j ] ) > THRESHOLD ) { 84 printf( "Pixel (%d, %d) is %.2f, should be %.2f\n", i, j, 85 outImage->data.F32[ i ][ j ], 86 tmpImage->data.F32[ i ][ j ] ); 87 } 88 89 } 78 for ( j = 0;j < IMAGE_SIZE;j++ ) { 79 80 // printf("pixel[%d][%d] is (%f, %f)\n", i, j, 81 // tmpImage->data.F32[i][j], 82 // outImage->data.F32[i][j]); 83 if ( fabs( outImage->data.F32[ i ][ j ] - tmpImage->data.F32[ i ][ j ] ) > THRESHOLD ) { 84 printf( "Pixel (%d, %d) is %.2f, should be %.2f\n", i, j, 85 outImage->data.F32[ i ][ j ], 86 tmpImage->data.F32[ i ][ j ] ); 87 } 88 90 89 } 91 90 } 91 92 92 psMemCheckCorruption( 1 ); 93 93 printFooter( stdout, … … 95 95 "Calculate Chebyshev Polynomials, no mask", 96 96 testStatus ); 97 97 98 98 /*************************************************************************/ 99 99 /* Deallocate data structures */ … … 106 106 psFree( outImage ); 107 107 psFree( my2DPoly ); 108 108 109 109 psMemCheckCorruption( 1 ); 110 110 memLeaks = psMemCheckLeaks( currentId, NULL, NULL ); 111 111 if ( 0 != memLeaks ) { 112 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );113 }114 112 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks ); 113 } 114 115 115 printFooter( stdout, 116 116 "psImageStats functions", 117 117 "Deallocate the psStats/psImage structure.", 118 118 testStatus ); 119 119 120 120 return ( !testStatus ); 121 121 }
Note:
See TracChangeset
for help on using the changeset viewer.
