Changeset 3878 for trunk/psModules/src/pmImageCombine.c
- Timestamp:
- May 10, 2005, 2:33:44 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmImageCombine.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmImageCombine.c
r3877 r3878 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-05-1 0 23:48:19$7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-05-11 00:33:44 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 #include "psPixels.h" 28 28 29 29 // 30 // The following macros define how big the initial pixel list will be, and 31 // how much it should be incremented when realloc'ed. 32 // 33 #define PS_COMBINE_IMAGE_INITIAL_PIXEL_LIST_LENGTH 100 34 #define PS_COMBINE_IMAGE_INITIAL_PIXEL_LIST_LENGTH_INC 100 30 35 /****************************************************************************** 31 36 pmCombineImages(combine, questionablePixels, images, errors, masks, maskVal, … … 93 98 PS_PTR_CHECK_NULL(stats, combine); 94 99 95 // Allocate an initialize the combined image, if necessary.100 // Allocate and initialize the combined image, if necessary. 96 101 if (combine == NULL) { 97 102 combine = psImageAlloc(numCols, numRows, PS_TYPE_F32); … … 100 105 } 101 106 } 107 108 // 109 // Allocate the questionablePixels psArray, if necesssary, then create a psPixels 110 // struct for each image. 111 // 112 if (*questionablePixels == NULL) { 113 *questionablePixels = psArrayAlloc(numImages); 114 } else if ((*questionablePixels)->n != numImages) { 115 *questionablePixels = psArrayRealloc(*questionablePixels, numImages); 116 } 117 for (psS32 im = 0 ; im < numImages ; im++) { 118 psFree((*questionablePixels)->data[im]); 119 ((*questionablePixels)->data[im]) = (psPtr *) psPixelsAlloc(PS_COMBINE_IMAGE_INITIAL_PIXEL_LIST_LENGTH); 120 } 121 // 122 // qpPtr is used to maintain a count of the questionable pixels for each image. 123 // 124 psVector *qpPtr = psVectorAlloc(numImages, PS_TYPE_S32); 125 PS_VECTOR_SET_S32(qpPtr, 0); 102 126 103 127 // … … 178 202 pixelMask->data.F32[im] = maskVal; 179 203 // 180 // XXX: Must Code This. 181 // XXX: Add this to the list of questionable pixels. 204 // XXX: These data structures indirections are getting complicated. 182 205 // 206 psS32 ptr = qpPtr->data.S32[im]; 207 psPixels *pixelListPtr = ((psPixels *) ((*questionablePixels)->data[im])); 208 if (ptr >= pixelListPtr->n) { 209 (*questionablePixels)->data[im] = (psPtr *) psPixelsRealloc(((psPixels *) ((*questionablePixels)->data[im])), ((((psPixels *) ((*questionablePixels)->data[im]))->n) + PS_COMBINE_IMAGE_INITIAL_PIXEL_LIST_LENGTH_INC)); 210 } 211 // XXX: Can the realloc() fail? Must we check for NULL? 212 ((psPixels *) ((*questionablePixels)->data[im]))->data[ptr].x = col; 213 ((psPixels *) ((*questionablePixels)->data[im]))->data[ptr].y = row; 214 (qpPtr->data.S32[im])++; 183 215 } 184 216 } … … 229 261 psFree(pixelMask); 230 262 psFree(pixelErrors); 231 263 psFree(qpPtr); 232 264 233 265 return(combine); … … 274 306 } 275 307 308 // 309 // The following macros define how big the initial pixel list will be, and 310 // how much it should be incremented when realloc'ed. 311 // 312 #define PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH 100 313 #define PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH_INC 100 276 314 /****************************************************************************** 277 315 pmRejectPixels(images, errors, inToOut, outToIn, rejThreshold, … … 302 340 // XXX: Loop through all images, ensure their sizes are equal? 303 341 342 // 343 // Create the psArray of psPixelLists, one for each image, for rejected pixels. 344 // 345 psArray *rejects = psArrayAlloc(numImages); 346 for (psS32 im = 0 ; im < numImages ; im++) { 347 rejects->data[im] = (psPtr *) psPixelsAlloc(PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH); 348 } 349 // 350 // rPtr is used to maintain a count of the questionable pixels for each image. 351 // 352 psVector *rPtr = psVectorAlloc(numImages, PS_TYPE_S32); 353 PS_VECTOR_SET_S32(rPtr, 0); 354 355 304 356 psS32 numCols = ((psImage *) images->data[0])->numCols; 305 357 psS32 numRows = ((psImage *) images->data[0])->numRows; … … 310 362 psPlane *outCoords = psAlloc(sizeof(psPlane)); 311 363 312 for (psS32 im g = 0 ; img < numImages ; img++) {364 for (psS32 im = 0 ; im < numImages ; im++) { 313 365 // 314 366 // Extract data from psArrays. 315 367 // 316 psPixels *pixelList = (psPixels *) errors->data[im g];317 psImage *currImage = (psImage *) images->data[im g];368 psPixels *pixelList = (psPixels *) errors->data[im]; 369 psImage *currImage = (psImage *) images->data[im]; 318 370 myRegion->x0 = 0; 319 371 myRegion->x1 = currImage->numCols - 1; 320 372 myRegion->y0 = 0; 321 373 myRegion->y1 = currImage->numRows - 1; 322 psPlaneTransform *myInToOut = (psPlaneTransform *) inToOut->data[im g];323 psPlaneTransform *myOutToIn = (psPlaneTransform *) outToIn->data[im g];374 psPlaneTransform *myInToOut = (psPlaneTransform *) inToOut->data[im]; 375 psPlaneTransform *myOutToIn = (psPlaneTransform *) outToIn->data[im]; 324 376 325 377 // … … 341 393 // 342 394 for (psS32 p = 0 ; p < pixelList->n ; p++) { 343 inCoords->x = 0.5 + (psF32) (pixelList->data )->x;344 inCoords->y = 0.5 + (psF32) (pixelList->data )->y;395 inCoords->x = 0.5 + (psF32) (pixelList->data[p]).x; 396 inCoords->y = 0.5 + (psF32) (pixelList->data[p]).y; 345 397 psPlaneTransformApply(outCoords, myInToOut, inCoords); 346 398 … … 358 410 // 359 411 for (psS32 otherImg = 0 ; otherImg < numImages ; otherImg++) { 360 if (im g!= otherImg) {412 if (im != otherImg) { 361 413 // Map the outCoords to inCoords that for otherImg space. 362 414 psPlaneTransformApply(inCoords, (psPlaneTransform * )outToIn->data[otherImg], outCoords); … … 383 435 if (meanGrads < gradLimit) { 384 436 // 385 // XXX: Add this to the list of questionable pixels.386 // XXX: Must Code This.437 // Add this to the list of questionable pixels. We must ensure that the 438 // pixelList is large enough; if not, we realloc() 387 439 // 440 psS32 ptr = rPtr->data.S32[im]; 441 psPixels *pixelListPtr = (psPixels *) rejects->data[im]; 442 if (ptr >= pixelListPtr->n) { 443 rejects->data[im] = (psPtr *) psPixelsRealloc(((psPixels *) rejects->data[im]), 444 ((((psPixels *) rejects->data[im])->n) + PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH_INC)); 445 } 446 // XXX: Can the realloc() fail? Must we check for NULL? 447 ((psPixels *) rejects->data[im])->data[ptr].x = (pixelList->data[p]).x; 448 ((psPixels *) rejects->data[im])->data[ptr].y = (pixelList->data[p]).y; 449 (rPtr->data.S32[im])++; 388 450 } 389 451 } … … 400 462 return(NULL); 401 463 } 402 // This code is 403 464
Note:
See TracChangeset
for help on using the changeset viewer.
