Changeset 3698
- Timestamp:
- Apr 13, 2005, 4:07:10 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmObjects.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmObjects.c
r3697 r3698 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-04-14 0 0:16:39$7 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-04-14 02:07:10 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 117 117 118 118 /****************************************************************************** 119 XXX: We don't free pixels and mask since that caused a memory error. 120 We might need to increase the reference counter and decrease it here. 121 *****************************************************************************/ 122 static void p_psSourceFree(psSource *tmp) 123 { 124 psFree(tmp->peak); 125 psFree(tmp->pixels); 126 psFree(tmp->mask); 127 psFree(tmp->moments); 128 psFree(tmp->models); 119 p_psSourceFree(tmp): a private function which frees the psSource struct. 120 *****************************************************************************/ 121 static void p_psSourceFree(psSource *tmpSrc) 122 { 123 psFree(tmpSrc->peak); 124 psFree(tmpSrc->pixels); 125 psFree(tmpSrc->mask); 126 psFree(tmpSrc->moments); 127 psFree(tmpSrc->models); 129 128 } 130 129 … … 135 134 psSource *pmSourceAlloc() 136 135 { 137 psSource *tmp = (psSource *) psAlloc(sizeof(psSource));138 tmp ->peak = NULL;139 tmp ->pixels = NULL;140 tmp ->mask = NULL;141 tmp ->moments = NULL;142 tmp ->models = NULL;143 psMemSetDeallocator(tmp , (psFreeFcn) p_psSourceFree);144 145 return(tmp );136 psSource *tmpSrc = (psSource *) psAlloc(sizeof(psSource)); 137 tmpSrc->peak = NULL; 138 tmpSrc->pixels = NULL; 139 tmpSrc->mask = NULL; 140 tmpSrc->moments = NULL; 141 tmpSrc->models = NULL; 142 psMemSetDeallocator(tmpSrc, (psFreeFcn) p_psSourceFree); 143 144 return(tmpSrc); 146 145 } 147 146 … … 155 154 XXX: We currently step through the input vector twice; once to determine the 156 155 size of the output vector, then to set the values of the output vector. 157 Depending upon actual use, this may need to be optimized. 156 Depending upon actual use, this may need to be optimized. Use the function 157 which adds to a psVector. It's not clear which way is faster. 158 158 *****************************************************************************/ 159 159 psVector *pmFindVectorPeaks(const psVector *vector, … … 250 250 251 251 XXX: Is there a better way to do this? 252 253 XXX: Use memcpy() on the data transfer. 252 254 *****************************************************************************/ 253 255 psVector *p_psGetRowVectorFromImage(psImage *image, … … 265 267 266 268 /****************************************************************************** 269 p_psGetColVectorFromImage(): a private function which simply returns a 270 psVector containing the specified col of data from the psImage. 271 272 XXX: Is there a better way to do this? 273 274 XXX: Use memcpy() on the data transfer. 275 *****************************************************************************/ 276 psVector *p_psGetColVectorFromImage(psImage *image, 277 psU32 col) 278 { 279 PS_IMAGE_CHECK_NULL(image, NULL); 280 PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, NULL); 281 282 psVector *tmpVector = psVectorAlloc(image->numRows, PS_TYPE_F32); 283 for (psU32 row = 0; row < image->numRows ; row++) { 284 tmpVector->data.F32[row] = image->data.F32[row][col]; 285 } 286 return(tmpVector); 287 } 288 289 /****************************************************************************** 267 290 MyListAddPeak(): A private function which allocates a psList, if the list 268 291 argument is NULL, otherwise it adds the peak to that list. 269 270 XXX: Switch row, col args?271 292 *****************************************************************************/ 272 293 psList *MyListAddPeak(psList *list, 294 psS32 col, 273 295 psS32 row, 274 psS32 col,275 296 psF32 counts, 276 297 psPeakType type) … … 332 353 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 333 354 if (image->data.F32[row][col] > threshold) { 334 list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);355 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 335 356 } 336 357 } … … 342 363 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 343 364 if (image->data.F32[row][col] > threshold) { 344 list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);365 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 345 366 } 346 367 } … … 351 372 (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) { 352 373 if (image->data.F32[row][col] > threshold) { 353 list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);374 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 354 375 } 355 376 } … … 386 407 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 387 408 myType = PM_PEAK_EDGE; 388 list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);409 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType); 389 410 } 390 411 } else if (col < (image->numCols - 1)) { … … 421 442 } 422 443 423 list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);444 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType); 424 445 } 425 446 } … … 433 454 (image->data.F32[row][col] >= image->data.F32[row+1][col])) { 434 455 myType = PM_PEAK_EDGE; 435 list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);456 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType); 436 457 } 437 458 } else { … … 455 476 (image->data.F32[row][col] > image->data.F32[row][col+1])) { 456 477 if (image->data.F32[row][col] > threshold) { 457 list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);478 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 458 479 } 459 480 } … … 465 486 (image->data.F32[row][col] >= image->data.F32[row][col+1])) { 466 487 if (image->data.F32[row][col] > threshold) { 467 list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);488 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 468 489 } 469 490 } … … 474 495 (image->data.F32[row][col] > image->data.F32[row][col-1])) { 475 496 if (image->data.F32[row][col] > threshold) { 476 list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);497 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 477 498 } 478 499 } … … 484 505 return(list); 485 506 } 507 508 509 #define PS_REGION_CHECK(VALID, X, Y) \ 510 (((X) >= (VALID)->x0) && \ 511 ((X) <= (VALID)->x1) && \ 512 ((Y) >= (VALID)->y0) && \ 513 ((Y) <= (VALID)->y1)) 486 514 487 515 // XXX: Macro this. … … 525 553 if ((tmpPeak->counts > maxValue) || 526 554 ((valid != NULL) && 527 (true == IsItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) { 555 // (true == IsItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) { 556 (true == PS_REGION_CHECK(valid, tmpPeak->x, tmpPeak->y)))) { 528 557 psListRemoveData(peaks, (psPtr) tmpPeak); 529 558 }
Note:
See TracChangeset
for help on using the changeset viewer.
