Changeset 4037
- Timestamp:
- May 25, 2005, 2:13:48 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmImageSubtract.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmImageSubtract.c
r4036 r4037 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-05-2 5 23:59:08 $7 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-05-26 00:13:48 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 // for convenience. 76 76 // 77 // XXX: replace (i, j) with (xOrder, yOrder) for clarity.78 //79 77 psS32 ptr = 0; 80 78 for (psS32 order = 0; order <= spatialOrder; order++) { 81 for (psS32 i = 0; i <= order; i++) {82 psS32 j = order - i;79 for (psS32 xOrder = 0; xOrder <= order; xOrder++) { 80 psS32 yOrder = order - xOrder; 83 81 tmp->u->data.F32[ptr] = 0; 84 82 tmp->v->data.F32[ptr] = 0; 85 tmp->xOrder->data.F32[ptr] = i;86 tmp->yOrder->data.F32[ptr] = j;83 tmp->xOrder->data.F32[ptr] = xOrder; 84 tmp->yOrder->data.F32[ptr] = yOrder; 87 85 ptr++; 88 86 } … … 100 98 // x^i * y^j such that (i+j) <= spatialOrder. 101 99 // 102 // XXX: replace (i, j) with (xOrder, yOrder) for clarity.103 //104 100 for (psS32 order = 0; order <= spatialOrder; order++) { 105 for (psS32 i = 0; i <= order; i++) {106 psS32 j = order - i;101 for (psS32 xOrder = 0; xOrder <= order; xOrder++) { 102 psS32 yOrder = order - xOrder; 107 103 tmp->u->data.F32[ptr] = 0; 108 104 tmp->v->data.F32[ptr] = 0; 109 tmp->xOrder->data.F32[ptr] = i;110 tmp->yOrder->data.F32[ptr] = j;105 tmp->xOrder->data.F32[ptr] = xOrder; 106 tmp->yOrder->data.F32[ptr] = yOrder; 111 107 ptr++; 112 108 } … … 177 173 // This loop creates 178 174 // 179 // XXX: Put the v loop before the u loop.180 // XXX: Put the orderYTerm loop before the orderXTerm loop.181 175 // XXX: must loop on the sigmas. 182 176 // … … 191 185 psImage *currKernel = (psImage *) psImageAlloc(1 + (2 * size), 1 + (2 * size), PS_TYPE_F32); 192 186 193 for (psS32 u = -xKernelHalfSize; u <= xKernelHalfSize; u++) {194 for (psS32 v = -yKernelHalfSize; v <= yKernelHalfSize; v++) {187 for (psS32 v = -yKernelHalfSize; v <= yKernelHalfSize; v++) { 188 for (psS32 u = -xKernelHalfSize; u <= xKernelHalfSize; u++) { 195 189 // Scale the (u,v) coordinates in kernel space to [-1.0:1.0]. 196 190 psF32 uScaled = ((psF32) (u - xKernelHalfSize)) / ((psF32) (1 + (2 * xKernelHalfSize))); … … 199 193 psF32 exponent = (PS_SQR(uScaled) * PS_SQR(vScaled)) / 200 194 (2.0 * PS_SQR(sigmas->data.F32[sigPtr])); 201 currKernel->data.F32[ u+xKernelHalfSize][v+yKernelHalfSize] =195 currKernel->data.F32[v+yKernelHalfSize][u+xKernelHalfSize] = 202 196 exp(exponent) * pow(uScaled, orderXTerm) + pow(vScaled, orderYTerm); 203 197 } … … 209 203 // 210 204 // sigPtr loops through each sigma value in the *sigmas argument. 211 // XXX: Put the v loop before the u loop.212 // XXX: Put the orderYTerm loop before the orderXTerm loop.213 205 // 214 206 psS32 ptr = 0; … … 250 242 psImage *currKernel = (psImage *) tmp->preCalc->data[ptr]; 251 243 252 for (psS32 u = -xKernelHalfSize; u <= xKernelHalfSize; u++) {253 for (psS32 v = -yKernelHalfSize; v <= yKernelHalfSize; v++) {244 for (psS32 v = -yKernelHalfSize; v <= yKernelHalfSize; v++) { 245 for (psS32 u = -xKernelHalfSize; u <= xKernelHalfSize; u++) { 254 246 // Scale the (u,v) coordinates in kernel space to [-1.0:1.0]. 255 247 psF32 uScaled = ((psF32) (u - xKernelHalfSize)) / ((psF32) (1 + (2 * xKernelHalfSize))); … … 259 251 psF32 exponent = (PS_SQR(uScaled) * PS_SQR(vScaled)) / 260 252 (2.0 * PS_SQR(sigmas->data.F32[sigPtr])); 261 currKernel->data.F32[ u+xKernelHalfSize][v+yKernelHalfSize] =253 currKernel->data.F32[v+yKernelHalfSize][u+xKernelHalfSize] = 262 254 exp(exponent) * pow(uScaled, orderXTerm) + pow(vScaled, orderYTerm); 263 255 } … … 274 266 } 275 267 276 // XXX: These should maybe be public, maybe private global, or private local.277 268 void p_pmStampFree(pmStamp *stamp) 278 269 { … … 282 273 } 283 274 284 // XXX: These should maybe be public, maybe private global, or private local.285 275 pmStamp *p_pmStampAlloc(pmStampStatus status) 286 276 { … … 328 318 if (stamps != NULL) { 329 319 PS_ASSERT_INT_EQUAL(stamps->n, (xNum * yNum), NULL); 330 // XXX: Ensure that a pmStamp struct exists at each psArray location. 320 // 321 // Ensure that a pmStamp struct exists at each psArray location. 322 // 331 323 for (psS32 s = 0 ; s < (xNum * yNum) ; s++) { 332 324 if (NULL == stamps->data[s]) { … … 367 359 // border of pixels from the image edge. 368 360 // 369 // XXX: verify this(numX, numY), then get rid of it.361 // XXX: verify (numX, numY), then get rid of it. 370 362 // 371 363 psS32 numX = xNum; … … 435 427 436 428 437 438 429 /******************************************************************************* 439 440 430 XXX: How is the spatial order factor calculated? Is it simply a x^iy^j power 441 eavaluated at the (x, y) center for the stamp? Why bother with the 2-D 442 polynomial in evaluating it? Finally, why is it scaled to the half-size of 443 the reference image? 431 evaluated at the (x, y) center for the stamp? Why bother with the 2-D 432 polynomial in evaluating it? 444 433 ******************************************************************************/ 445 434 bool pmSubtractionCalculateEquation(psArray *stamps, ///< The stamps for which to calculate the equation, … … 515 504 // Iterate over all pixels surrounding this stamp. 516 505 // 517 // XXX: I modified the y,x loop order, and an [x][y] reference (1.0/reference->data.F32[y][x]).518 // Verify it.519 //520 506 for (psS32 y = stamp->y - footprint; y < stamp->y + footprint; y++) { 521 507 for (psS32 x = stamp->x - footprint; x < stamp->x + footprint; x++) { … … 547 533 conv1 -= reference->data.F32[y][x]; 548 534 } 549 550 535 551 536 // … … 710 695 It returns the value of the convolved pixel. 711 696 712 XXX: Parameter checks?713 714 697 XXX: Static structure for polyValues? 715 698 ******************************************************************************/ … … 772 755 the set of kernel basis functions and their appropriate weights in solution. 773 756 It returns the value of the convolved pixel. 774 775 XXX: Parameter checks?776 757 777 758 XXX: Static structure for polyValues? … … 830 811 ConvolveImage(input, mask, badStampMaskVal, solution, kernels): convolves an 831 812 arbitrary image with either an ISIS or POIS set of kernel basis functions. 832 833 XXX: Function decomposition: create a function which convolves a single834 function with a set of POIS kernel basis functions. Create another for ISIS835 kernel basis functions. Then rewrite this.836 813 ******************************************************************************/ 837 814 psImage *ConvolveImage(const psImage *input, … … 989 966 } 990 967 991 992 993 968 psFree(stats); 994 969 psFree(subStamp); … … 996 971 return deviations; 997 972 } 998 999 1000 1001 973 1002 974 /******************************************************************************* … … 1081 1053 1082 1054 /******************************************************************************* 1083 XXX: There are definite (x, y) (row, col) problems here.1084 1055 ******************************************************************************/ 1085 1056 psImage *pmSubtractionKernelImage(psImage *out, … … 1094 1065 PS_ASSERT_FLOAT_WITHIN_RANGE(x, -1.0, 1.0, NULL); 1095 1066 PS_ASSERT_FLOAT_WITHIN_RANGE(y, -1.0, 1.0, NULL); 1096 // XXX: Assert that all vectors and arrays in kernels are of the same length. 1067 PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->v, NULL); 1068 PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->xOrder, NULL); 1069 PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->yOrder, NULL); 1070 PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->preCalc, NULL); 1071 PS_ASSERT_INT_EQUAL(1+kernels->u->n, solution->n, NULL); 1072 1097 1073 psS32 nBF = kernels->u->n; 1098 1074 psS32 spatialOrder = kernels->p_spatialOrder;
Note:
See TracChangeset
for help on using the changeset viewer.
