Changeset 4036 for trunk/psModules/src/pmImageSubtract.c
- Timestamp:
- May 25, 2005, 1:59:08 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmImageSubtract.c (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmImageSubtract.c
r4035 r4036 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-05-25 23: 08:33$7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-05-25 23:59:08 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 * 12 * XXX: sync with iFa on this: 13 * The (x, y) (row, col) issue is becoming a problem. In this file, and I 14 * think, the rest of psLib and psModules, the following conventions are used: 15 * 16 * 1) x will correspond to the column, and y will correspond to the row. 17 * 2) When used in function prototypes, the column (and hence x) appears 18 * first. 19 * 3) When used to index 2-D arrays, obviously, the row (and hence, y) 20 * appears first. (2 and 3 are the source of confusion). 21 * 4) When (u, v) are used in certain structures. 22 * u corresponds to x 23 * v corresponds to y 24 * 5) When element (a, b) is casually referred to in comments, or 25 * documentation it is unclear where a is the row, or the column. 26 * 6) A convention on loop index variables (i, j) would be convenient. 27 * Currently, sometimes i corresponds to the column (x), 28 * usually it corresponds to the row (y). 11 29 * 12 30 */ … … 18 36 #include "pmImageSubtract.h" 19 37 20 // XXX: Put this is psConstants.h21 #define PS_ASSERT_VECTOR_SIZE(VEC, SIZE, RVAL) \22 if (VEC->n != SIZE) { \23 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \24 "psVector %s has size %d, should be %d." \25 #VEC, VEC->n, SIZE); \26 return(RVAL); \27 }28 29 38 /******************************************************************************* 30 XXX: Store the size and spatialOrder in a private member of the31 39 psSubtractionKernels struct. 32 40 ******************************************************************************/ … … 67 75 // for convenience. 68 76 // 77 // XXX: replace (i, j) with (xOrder, yOrder) for clarity. 78 // 69 79 psS32 ptr = 0; 70 80 for (psS32 order = 0; order <= spatialOrder; order++) { … … 89 99 // Iterate over spatial order. This loop creates the terms for 90 100 // x^i * y^j such that (i+j) <= spatialOrder. 101 // 102 // XXX: replace (i, j) with (xOrder, yOrder) for clarity. 91 103 // 92 104 for (psS32 order = 0; order <= spatialOrder; order++) { … … 132 144 psS32 numSigmas = sigmas->n; 133 145 psS32 nBF = 0; 134 for (psS32 i = 0 ; i < numSigmas ; i++) {146 for (psS32 s = 0 ; s < numSigmas ; s++) { 135 147 nBF+= ((orders->n + 1) * (orders->n + 2) / 2); 136 148 } … … 146 158 // XXX: There should be a macro or a psLib vectorDuplicate(). 147 159 tmp->sigma = psVectorAlloc(numSigmas, PS_TYPE_F32); 148 for (psS32 i = 0 ; i < numSigmas ; i++) {149 tmp->sigma->data.F32[ i] = sigmas->data.F32[i];160 for (psS32 s = 0 ; s < numSigmas ; s++) { 161 tmp->sigma->data.F32[s] = sigmas->data.F32[s]; 150 162 } 151 163 tmp->xOrder = psVectorAlloc(nBF, PS_TYPE_F32); … … 165 177 // This loop creates 166 178 // 167 // 168 // 179 // XXX: Put the v loop before the u loop. 180 // XXX: Put the orderYTerm loop before the orderXTerm loop. 169 181 // XXX: must loop on the sigmas. 182 // 170 183 psS32 sigPtr = 0; 171 184 // XXX: Review ptr. … … 175 188 for (psS32 orderXTerm = 0; orderXTerm <= order; orderXTerm++) { 176 189 psS32 orderYTerm = order - orderXTerm; 177 // psS32 imgPtr = orderYTerm + (orderXTerm * spatialOrder);190 // psS32 imgPtr = orderYTerm + (orderXTerm * spatialOrder); 178 191 psImage *currKernel = (psImage *) psImageAlloc(1 + (2 * size), 1 + (2 * size), PS_TYPE_F32); 179 192 … … 194 207 } 195 208 196 197 209 // 198 210 // 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 // 199 214 psS32 ptr = 0; 200 215 for (psS32 sigPtr = 0 ; sigPtr < numSigmas ; sigPtr++) { … … 218 233 for (psS32 order = 0; order <= spatialOrder; order++) { 219 234 for (psS32 orderXTerm = 0; orderXTerm <= order; orderXTerm++) { 235 psS32 orderYTerm = order - orderXTerm; 236 220 237 // XXX: Should simply add a pointer to an existing image and increase 221 238 // the memory reference counter for equivalent spatial orders. … … 227 244 } 228 245 229 psS32 orderYTerm = order - orderXTerm;230 246 tmp->u->data.F32[ptr] = xOrderP; 231 247 tmp->v->data.F32[ptr] = yOrderP; … … 331 347 // 332 348 psS32 num = 0; 333 for (psS32 i = 0; i < xNum; i++) {334 for (psS32 j = 0; j < yNum; j++) {349 for (psS32 j = 0; j < yNum; j++) { 350 for (psS32 i = 0; i < xNum; i++) { 335 351 pmStamp *stamp = (pmStamp *) stamps->data[num]; 336 352 … … 351 367 // border of pixels from the image edge. 352 368 // 353 // XXX: must set these 354 psS32 numX = 0; 355 psS32 numY = 0; 356 for (psS32 x = border + i * (numRows - 2.0 * border) / numX; 357 x < border + (i + 1) * (numRows - 2.0 * border) / numX; x++) { 358 for (psS32 y = border + j * (numCols - 2.0 * border) / numY; 359 y < border + (j + 1) * (numCols - 2.0 * border) / numY; y++) { 369 // XXX: verify this (numX, numY), then get rid of it. 370 // 371 psS32 numX = xNum; 372 psS32 numY = yNum; 373 for (psS32 y = border + j * (numCols - 2.0 * border) / numY; 374 y < border + (j + 1) * (numCols - 2.0 * border) / numY; y++) { 375 for (psS32 x = border + i * (numRows - 2.0 * border) / numX; 376 x < border + (i + 1) * (numRows - 2.0 * border) / numX; x++) { 360 377 361 378 // Determine if this pixel is larger than the max, and unmasked. 362 if ((image->data.F32[ x][y] > max) &&363 !(mask->data.U8[ x][y] & mask->data.U8[x][y])) {364 max = image->data.F32[ x][y];379 if ((image->data.F32[y][x] > max) && 380 !(mask->data.U8[y][x] & mask->data.U8[y][x])) { 381 max = image->data.F32[y][x]; 365 382 bestx = x; 366 383 besty = y; … … 373 390 // Otherwise, mark the stamp as PM_STAMP_NONE 374 391 // 375 if (image->data.F32[best x][besty] > threshold) {392 if (image->data.F32[besty][bestx] > threshold) { 376 393 stamp->x = bestx; 377 394 stamp->y = besty; … … 394 411 395 412 XXX: Modify loop so that terms higher than spatialOrder are not computed. 413 414 XXX: Modify this so that [i][j] location is calculated as (x^j * y^i)? 396 415 ******************************************************************************/ 397 416 static psImage *GenSpatialOrder(psS32 spatialOrder, … … 490 509 // 491 510 psImage *polyValues = GenSpatialOrder(spatialOrder, 492 ((psF64) (stamp-> y- numHalfCols)) / ((psF64) numHalfCols),493 ((psF64) (stamp-> x- numHalfRows)) / ((psF64) numHalfRows));511 ((psF64) (stamp->x - numHalfCols)) / ((psF64) numHalfCols), 512 ((psF64) (stamp->y - numHalfRows)) / ((psF64) numHalfRows)); 494 513 495 514 // 496 515 // Iterate over all pixels surrounding this stamp. 497 516 // 517 // XXX: I modified the y,x loop order, and an [x][y] reference (1.0/reference->data.F32[y][x]). 518 // Verify it. 498 519 // 499 for (psS32 x = stamp->x - footprint; x < stamp->x + footprint; x++) {500 for (psS32 y = stamp->y - footprint; y < stamp->y + footprint; y++) {501 psF32 invNoise2 = 1.0/reference->data.F32[ x][y]; // The inverse of the noise, squared.520 for (psS32 y = stamp->y - footprint; y < stamp->y + footprint; y++) { 521 for (psS32 x = stamp->x - footprint; x < stamp->x + footprint; x++) { 522 psF32 invNoise2 = 1.0/reference->data.F32[y][x]; // The inverse of the noise, squared. 502 523 503 524 // XXX: Think about a better decomposition of the computation … … 711 732 psF32 imageX = (((psF32) col) - numColsHalf) / numColsHalf; // Normalised position 712 733 psF32 imageY = (((psF32) row) - numRowsHalf) / numRowsHalf; // Normalised position 713 714 // XXX: Ensure you have the (x, y) order correct.715 734 psImage *polyValues = GenSpatialOrder(spatialOrder, imageX, imageY); 716 735 … … 722 741 // XXX: What's the story with this? 723 742 #if 0 724 // XXX: x/y order correct? 743 725 744 psS32 xOrder = (psS32) kernels->xOrder->data.F32[k]; 726 745 psS32 yOrder = (psS32) kernels->yOrder->data.F32[k]; … … 777 796 psF32 imageX = (((psF32) col) - numColsHalf) / numColsHalf; // Normalised position 778 797 psF32 imageY = (((psF32) row) - numRowsHalf) / numRowsHalf; // Normalised position 779 780 // XXX: Ensure you have the (x, y) order correct.781 798 psImage *polyValues = GenSpatialOrder(spatialOrder, imageX, imageY); 782 799 … … 785 802 // XXX: What's the story with this? 786 803 #if 0 787 // XXX: x/y order correct?788 804 psS32 xOrder = (psS32) kernels->xOrder->data.F32[k]; 789 805 psS32 yOrder = (psS32) kernels->yOrder->data.F32[k]; … … 798 814 for (psS32 xx = -kernelSize ; xx < kernelSize ; xx++) { 799 815 // XXX: Should I do something special for the k==0 kernel? 800 // The POIS code does.801 802 816 conv += solution->data.F64[k] * 803 817 input->data.F32[yy+row][xx+col] * … … 943 957 psS32 y = stamp->y; // Stamp y coord 944 958 if (stamp->status == PM_STAMP_USED) { 945 // XXX: Verify proper x,y order 946 psRegion myReg = psRegionSet(y - ySize, y + ySize, x - xSize, x + xSize); 959 psRegion myReg = psRegionSet(x - xSize, x + xSize, y - ySize, y + ySize); 947 960 psImage *refStamp = psImageSubset((psImage *) refImage, myReg); 948 961 psImage *inStamp = psImageSubset((psImage *) inImage, myReg); … … 954 967 (void)psBinaryOp(subStamp, subStamp, "/", inStamp); 955 968 (void)psBinaryOp(subStamp, subStamp, "*", subStamp); 956 // XXX: Verify proper x,y order957 969 myReg = psRegionSet(kernelSize, kernelSize + 2 * footprint, 958 970 kernelSize, kernelSize + 2 * footprint); … … 1069 1081 1070 1082 /******************************************************************************* 1083 XXX: There are definite (x, y) (row, col) problems here. 1071 1084 ******************************************************************************/ 1072 1085 psImage *pmSubtractionKernelImage(psImage *out, … … 1107 1120 // centered at the specified (x, y) position. 1108 1121 // 1109 numRows = (psS32) ceilf( ((psF32) kernelSize) / (( x+ 1.0)/2.0));1110 numRows = PS_MAX(numRows, (((psF32) kernelSize) / (1.0 - (( x+ 1.0)/2.0))));1122 numRows = (psS32) ceilf( ((psF32) kernelSize) / ((y + 1.0)/2.0)); 1123 numRows = PS_MAX(numRows, (((psF32) kernelSize) / (1.0 - ((y + 1.0)/2.0)))); 1111 1124 numCols = (psS32) ceilf( ((psF32) kernelSize) / ((x + 1.0)/2.0)); 1112 1125 numCols = PS_MAX(numRows, (((psF32) kernelSize) / (1.0 - ((x + 1.0)/2.0)))); … … 1119 1132 PS_IMAGE_SET_F32(out, 0.0); 1120 1133 1134 // XXX: switch (i, j) so they correspond to (x, y). 1121 1135 if (kernels->type == PM_SUBTRACTION_KERNEL_ISIS) { 1122 1136 for (psS32 k = 0 ; k < nBF ; k++) { … … 1143 1157 psS32 xOrder = kernels->xOrder->data.F32[nBF]; 1144 1158 psS32 yOrder = kernels->yOrder->data.F32[nBF]; 1145 // XXX: Verify that (u, v) correspond to (x, y) and that we have the row,col stuff correct.1146 // XXX: Verify the same for xOrder,yOrder.1147 1159 // XXX: Verify that this is correct. 1148 1160 out->data.F32[yCenter - (psS32) v][xCenter - (psS32) u]+= solution->data.F64[nBF] * … … 1154 1166 return(out); 1155 1167 } 1156 // This code is
Note:
See TracChangeset
for help on using the changeset viewer.
