Changeset 14860
- Timestamp:
- Sep 16, 2007, 9:16:39 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070830/psLib/test/imageops/tap_psImageMapFit.c
r14859 r14860 19 19 # define TEST_4PT_3 0 20 20 21 # define TEST_6PT_0 0 22 21 23 # define TEST_9PT_0 0 22 24 # define TEST_9PT_1 0 23 # define TEST_9PT_2 0 24 25 # define TEST_6PT_0 1 25 # define TEST_9PT_2 1 26 26 27 27 # define TEST1 0 … … 58 58 int n = 0; 59 59 for (float ix = 0.5; ix < 3.0; ix += 1.0) { 60 for (int iy = 0.5; iy < 2.0; iy += 1.0) { 61 x->data.F32[n] = ix; 62 y->data.F32[n] = iy; 63 # if (0) 60 for (float iy = 0.5; iy < 2.0; iy += 1.0) { 61 // x->data.F32[n] = ix; 62 // y->data.F32[n] = iy; 63 if ((ix == 0.5) && (iy == 0.5)) { 64 x->data.F32[n] = ix + 0.0; 65 y->data.F32[n] = iy + 0.1; // add in both points. 66 // f->data.F32[n] = x->data.F32[n] + y->data.F32[n]; 67 // n++; 68 // x->data.F32[n] = ix + 0.0; 69 // y->data.F32[n] = iy - 0.1; 70 } else { 71 x->data.F32[n] = ix; 72 y->data.F32[n] = iy; 73 } 74 f->data.F32[n] = x->data.F32[n] + y->data.F32[n]; 75 n++; 76 } 77 } 78 x->n = n; 79 y->n = n; 80 f->n = n; 81 82 psImage *field = psImageAlloc(3, 2, PS_TYPE_F32); 83 for (int ix = 0; ix < 3; ix++) { 84 for (int iy = 0; iy < 2; iy++) { 85 field->data.F32[iy][ix] = (ix + 0.5) + (iy + 0.5); 86 } 87 } 88 89 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 90 91 // scale defines both field and map image sizes (nXfine, nXruff) 92 psImageMap *map = psImageMapAlloc (NULL, binning, stats); 93 94 // fit the data to the map 95 psImageMapFit (map, x, y, f, NULL); 96 psFree (binning); 97 98 SaveImage (NULL, map->map, "map.fits"); 99 100 SaveImage (NULL, field, "field.fits"); 101 102 psImage *model = psImageAlloc(field->numCols, field->numRows, PS_TYPE_F32); 103 for (int ix = 0; ix < model->numCols; ix++) { 104 for (int iy = 0; iy < model->numRows; iy++) { 105 model->data.F32[iy][ix] = psImageUnbinPixel_V2 (ix + 0.5, iy + 0.5, map->map, map->binning); 106 is_float_tol (model->data.F32[iy][ix], field->data.F32[iy][ix], FLT_EPSILON, "model matches inputs"); 107 } 108 } 109 SaveImage (NULL, model, "model.fits"); 110 // ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 111 } 112 # endif 113 114 // test for more points: 3x3 grid fitted to 9 points with simple slope and scale difference 115 # if (TEST_9PT_2) 116 { 117 psImageBinning *binning = psImageBinningAlloc(); 118 binning->nXfine = 6; 119 binning->nYfine = 6; 120 binning->nXruff = 3; 121 binning->nYruff = 3; 122 123 // generate a grid of test data points 124 psVector *x = psVectorAlloc (50, PS_TYPE_F32); 125 psVector *y = psVectorAlloc (50, PS_TYPE_F32); 126 psVector *f = psVectorAlloc (50, PS_TYPE_F32); 127 128 // the underlying field is f = ix + iy, where ix,iy are fine pixel coordinates 129 // place the measurement points exactly on the ruff reference pixel centers 130 int n = 0; 131 for (float ix = 1.0; ix < 6; ix += 2.0) { 132 for (float iy = 1.0; iy < 6; iy += 2.0) { 64 133 if ((ix == 3.0) && (iy == 1.0)) { 65 134 x->data.F32[n] = ix + 0.0; 66 135 y->data.F32[n] = iy + 0.1; // add in both points. 67 f->data.F32[n] = ix + iy;136 f->data.F32[n] = x->data.F32[n] + y->data.F32[n]; 68 137 n++; 69 138 x->data.F32[n] = ix + 0.0; … … 73 142 y->data.F32[n] = iy; 74 143 } 75 # endif 76 f->data.F32[n] = ix + iy; 144 f->data.F32[n] = x->data.F32[n] + y->data.F32[n]; 77 145 n++; 78 146 } … … 82 150 f->n = n; 83 151 84 psImage *field = psImageAlloc( 3, 2, PS_TYPE_F32);85 for (int ix = 0; ix < 3; ix++) {86 for (int iy = 0; iy < 2; iy++) {152 psImage *field = psImageAlloc(6, 6, PS_TYPE_F32); 153 for (int ix = 0; ix < 6; ix++) { 154 for (int iy = 0; iy < 6; iy++) { 87 155 field->data.F32[iy][ix] = (ix + 0.5) + (iy + 0.5); 88 156 } … … 114 182 # endif 115 183 116 // test for more points: 3x3 grid fitted to 9 points with simple slope and scale difference117 # if (TEST_9PT_ 2)184 // still a simple test: 3x3 grid fitted to 9 points with simple slope and scale difference 185 # if (TEST_9PT_1) 118 186 { 119 187 psImageBinning *binning = psImageBinningAlloc(); … … 124 192 125 193 // generate a grid of test data points 126 psVector *x = psVectorAlloc (50, PS_TYPE_F32);127 psVector *y = psVectorAlloc (50, PS_TYPE_F32);128 psVector *f = psVectorAlloc (50, PS_TYPE_F32);129 130 // the underlying field is f = ix + iy, where ix,iy are fine pixel coordinates131 // place the measurement points exactly on the ruff reference pixel centers132 int n = 0;133 for (float ix = 1.0; ix < 6; ix += 2.0) {134 for (int iy = 1.0; iy < 6; iy += 2.0) {135 if ((ix == 3.0) && (iy == 1.0)) {136 x->data.F32[n] = ix + 0.0;137 y->data.F32[n] = iy + 0.1; // add in both points.138 f->data.F32[n] = ix + iy;139 n++;140 x->data.F32[n] = ix + 0.0;141 y->data.F32[n] = iy - 0.1;142 } else {143 x->data.F32[n] = ix;144 y->data.F32[n] = iy;145 }146 f->data.F32[n] = ix + iy;147 n++;148 }149 }150 x->n = n;151 y->n = n;152 f->n = n;153 154 psImage *field = psImageAlloc(6, 6, PS_TYPE_F32);155 for (int ix = 0; ix < 6; ix++) {156 for (int iy = 0; iy < 6; iy++) {157 field->data.F32[iy][ix] = (ix + 0.5) + (iy + 0.5);158 }159 }160 161 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);162 163 // scale defines both field and map image sizes (nXfine, nXruff)164 psImageMap *map = psImageMapAlloc (NULL, binning, stats);165 166 // fit the data to the map167 psImageMapFit (map, x, y, f, NULL);168 psFree (binning);169 170 SaveImage (NULL, map->map, "map.fits");171 172 SaveImage (NULL, field, "field.fits");173 174 psImage *model = psImageAlloc(field->numCols, field->numRows, PS_TYPE_F32);175 for (int ix = 0; ix < model->numCols; ix++) {176 for (int iy = 0; iy < model->numRows; iy++) {177 model->data.F32[iy][ix] = psImageUnbinPixel_V2 (ix + 0.5, iy + 0.5, map->map, map->binning);178 is_float_tol (model->data.F32[iy][ix], field->data.F32[iy][ix], FLT_EPSILON, "model matches inputs");179 }180 }181 SaveImage (NULL, model, "model.fits");182 // ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");183 }184 # endif185 186 // still a simple test: 3x3 grid fitted to 9 points with simple slope and scale difference187 # if (TEST_9PT_1)188 {189 psImageBinning *binning = psImageBinningAlloc();190 binning->nXfine = 6;191 binning->nYfine = 6;192 binning->nXruff = 3;193 binning->nYruff = 3;194 195 // generate a grid of test data points196 194 psVector *x = psVectorAlloc (9, PS_TYPE_F32); 197 195 psVector *y = psVectorAlloc (9, PS_TYPE_F32); … … 205 203 x->data.F32[n] = ix; 206 204 y->data.F32[n] = iy; 207 f->data.F32[n] = ix + iy;205 f->data.F32[n] = x->data.F32[n] + y->data.F32[n]; 208 206 n++; 209 207 } … … 263 261 x->data.F32[n] = ix + 0.5; 264 262 y->data.F32[n] = iy + 0.5; 265 f->data.F32[n] = ix + iy;263 f->data.F32[n] = x->data.F32[n] + y->data.F32[n]; 266 264 field->data.F32[iy][ix] = f->data.F32[n]; 267 265 n++; … … 377 375 for (int iy = 0; iy < 2; iy++) { 378 376 // add in one extra point on the surface 377 if (!ix && !iy) { 378 x->data.F32[n] = ix + 0.5; 379 y->data.F32[n] = iy + 0.5 + 0.1; 380 } else { 381 x->data.F32[n] = ix + 0.5; 382 y->data.F32[n] = iy + 0.5; 383 } 384 # if (0) 379 385 if (ix) { 380 386 x->data.F32[n] = ix + 0.5 - 0.1; … … 387 393 y->data.F32[n] = iy + 0.5 + 0.1; 388 394 } 395 # endif 389 396 f->data.F32[n] = x->data.F32[n] + y->data.F32[n]; 390 397 field->data.F32[iy][ix] = ix + 0.5 + iy + 0.5; … … 439 446 x->data.F32[n] = ix; 440 447 y->data.F32[n] = iy; 441 f->data.F32[n] = ix + iy;448 f->data.F32[n] = x->data.F32[n] + y->data.F32[n]; 442 449 n++; 443 450 }
Note:
See TracChangeset
for help on using the changeset viewer.
