Changeset 1870 for trunk/psModules/src/tst_pmMaskBadPixels.c
- Timestamp:
- Sep 23, 2004, 1:33:54 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/tst_pmMaskBadPixels.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/tst_pmMaskBadPixels.c
r1832 r1870 1 2 /** @file filename.h 1 /** @file tst_pmMaskBadPixels.c 3 2 * 4 * @brief Contains the definitions for ... 5 * 6 * Detailed Description goes here. 3 * @brief Contains the tests for pmMaskBadPixels: 7 4 * 8 5 * @author Ross Harman, MHPCC 9 6 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-09-2 0 20:36:46$7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-09-23 23:33:54 $ 12 9 * 13 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 14 11 */ 15 12 13 14 #include "psTest.h" 15 #include "pslib.h" 16 16 #include "pmMaskBadPixels.h" 17 17 18 18 19 #define PRINT_MATRIX(IMAGE,TYPE) \ 20 for(int i=0; i<IMAGE->numRows; i++) { \ 21 for(int j=0; j<IMAGE->numCols; j++) { \ 22 if(PS_IS_PSELEMTYPE_COMPLEX(IMAGE->type.type)) { \ 23 printf("%f+%fi ", creal(IMAGE->data.TYPE[i][j]), cimag(IMAGE->data.TYPE[i][j])); \ 24 } else if(PS_IS_PSELEMTYPE_INT(IMAGE->type.type)) { \ 25 printf("%d", (int)IMAGE->data.TYPE[i][j]); \ 26 } else { \ 27 printf("%f ", (double)IMAGE->data.TYPE[i][j]); \ 28 } \ 29 } \ 30 printf("\n"); \ 31 } \ 19 #define PRINT_MATRIX(IMAGE,TYPE,STRING) \ 20 printf(STRING); \ 21 printf("\n"); \ 22 for(int i=IMAGE->numRows-1; i>-1; i--) { \ 23 for(int j=0; j<IMAGE->numCols; j++) { \ 24 if(PS_IS_PSELEMTYPE_COMPLEX(IMAGE->type.type)) { \ 25 printf("%f+%fi ", creal(IMAGE->data.TYPE[i][j]), cimag(IMAGE->data.TYPE[i][j])); \ 26 } else if(PS_IS_PSELEMTYPE_INT(IMAGE->type.type)) { \ 27 printf("%d", (int)IMAGE->data.TYPE[i][j]); \ 28 } else { \ 29 printf("%f", (double)IMAGE->data.TYPE[i][j]); \ 30 } \ 31 } \ 32 printf("\n"); \ 33 } \ 32 34 printf("\n"); 33 35 34 36 35 int main(void) 36 { 37 int grow = 10; 38 int size = 50; 39 unsigned int maskVal = 0; 40 unsigned int growVal = 1; 41 float sat = 100.0f; 42 psImage *inImage = psImageAlloc(size, size, PS_TYPE_F64); 43 psImage *mask1 = psImageAlloc(size, size, PS_TYPE_MASK); 44 psImage *mask2 = psImageAlloc(size, size, PS_TYPE_MASK); 45 psReadout *inReadout = psReadoutAlloc(0, 0, inImage); 37 #define CREATE_AND_SET_IMAGE(NAME,TYPE,VALUE,NROWS,NCOLS) \ 38 psImage *NAME = (psImage*)psImageAlloc(NCOLS,NROWS,PS_TYPE_##TYPE); \ 39 for(int i=0; i<NAME->numRows; i++) { \ 40 for(int j=0; j<NAME->numCols; j++) { \ 41 NAME->data.TYPE[i][j] = VALUE; \ 42 } \ 43 } 46 44 47 45 48 for(int r=0;r<size;r++) { 49 for(int c=0;c<size;c++) { 50 inImage->data.F64[r][c]=6.0; 51 mask1->data.PS_TYPE_MASK_DATA[r][c]=0; 52 mask2->data.PS_TYPE_MASK_DATA[r][c]=0; 53 } 54 } 46 static int testMaskBadPixels(void); 55 47 48 49 testDescription tests[] = { 50 {testMaskBadPixels, 885, "pmMaskBadPixels", 0, false}, 51 {NULL} 52 }; 53 54 55 int main(int argc, char* argv[]) 56 { 57 return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv); 58 } 59 60 61 int testMaskBadPixels( void ) 62 { 63 64 65 // Test A - Create mask based on maskVal argument 66 printPositiveTestHeader(stdout, "pmMaskBadPixels", "Test A - Create mask based on maskVal argument"); 67 CREATE_AND_SET_IMAGE(inImage1,F64,0,50,50); 68 CREATE_AND_SET_IMAGE(mask1,U8,0,50,50) 69 psReadout *inReadout = psReadoutAlloc(0, 0, inImage1); 56 70 mask1->data.PS_TYPE_MASK_DATA[24][24]=1; 57 PRINT_MATRIX(inImage,F64); 58 PRINT_MATRIX(mask1, PS_TYPE_MASK_DATA); 59 pmMaskBadPixels(inReadout, mask1, maskVal, sat, growVal, grow); 60 PRINT_MATRIX(inReadout->mask, PS_TYPE_MASK_DATA); 71 PRINT_MATRIX(mask1, U8, "Data mask:"); 72 pmMaskBadPixels(inReadout, mask1, 1, 100.0, 0, 0); 73 PRINT_MATRIX(inReadout->mask, U8, "Resulting mask:"); 74 psFree(mask1); 75 psFree(inReadout); 76 psFree(inImage1); 77 printFooter(stdout, "pmMaskBadPixels", "Test A - Create mask based on maskVal argument", true); 78 printf("\n\n\n"); 79 80 81 // Test B - Create mask based on saturation argument 82 printPositiveTestHeader(stdout, "pmMaskBadPixels", "Test B - Create mask based on saturation argument"); 83 CREATE_AND_SET_IMAGE(inImage2,F64,150.0,50,50); 84 CREATE_AND_SET_IMAGE(mask2,U8,0,50,50) 85 psReadout *inReadout2 = psReadoutAlloc(0, 0, inImage2); 86 PRINT_MATRIX(mask2, U8, "Data mask:"); 87 pmMaskBadPixels(inReadout2, mask2, 0, 100.0, 0, 0); 88 PRINT_MATRIX(inReadout2->mask, U8, "Resulting mask:"); 89 psFree(mask2); 90 psFree(inReadout2); 91 psFree(inImage2); 92 printFooter(stdout, "pmMaskBadPixels", "Test B - Create mask based on saturation argument", true); 93 printf("\n\n\n"); 94 95 96 // Test C - Create mask based on growVal and grow arguments 97 printPositiveTestHeader(stdout, "pmMaskBadPixels", "Test C - Create mask based on growVal and grow arguments"); 98 CREATE_AND_SET_IMAGE(inImage3,F64,50.0,50,50); 99 CREATE_AND_SET_IMAGE(mask3,U8,0,50,50) 100 psReadout *inReadout3 = psReadoutAlloc(0, 0, inImage3); 101 mask3->data.PS_TYPE_MASK_DATA[24][24]=1; 102 PRINT_MATRIX(mask3, U8, "Data mask:"); 103 pmMaskBadPixels(inReadout3, mask3, 0, 100.0, 1, 10); 104 PRINT_MATRIX(inReadout3->mask, U8, "Resulting mask:"); 105 psFree(mask3); 106 psFree(inReadout3); 107 psFree(inImage3); 108 printFooter(stdout, "pmMaskBadPixels", "Test C - Create mask based on growVal and grow arguments", true); 109 printf("\n\n\n"); 110 111 112 // Test D - Create mask based on maskVal argument starting with non-null mask 113 printPositiveTestHeader(stdout, "pmMaskBadPixels", "Test D - Create mask based on maskVal argument starting with non-null mask"); 114 CREATE_AND_SET_IMAGE(inImage4,F64,50.0,50,50); 115 CREATE_AND_SET_IMAGE(mask4,U8,0,50,50) 116 CREATE_AND_SET_IMAGE(mask4i,U8,0,50,50) 117 psReadout *inReadout4 = psReadoutAlloc(0, 0, inImage4); 118 inReadout4->mask = mask4i; 119 mask4->data.PS_TYPE_MASK_DATA[24][24]=1; 120 PRINT_MATRIX(mask4, U8, "Data mask:"); 121 pmMaskBadPixels(inReadout4, mask4, 0, 100.0, 1, 10); 122 PRINT_MATRIX(inReadout4->mask, U8, "Resulting mask:"); 123 psFree(mask4); 124 psFree(inReadout4); 125 psFree(inImage4); 126 printFooter(stdout, "pmMaskBadPixels", "Test D - Create mask based on maskVal argument starting with non-null mask", true); 127 printf("\n\n\n"); 128 129 61 130 return 0; 62 131 }
Note:
See TracChangeset
for help on using the changeset viewer.
