Changeset 10048 for trunk/psModules/src/objects/pmPeaks.c
- Timestamp:
- Nov 17, 2006, 1:00:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPeaks.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPeaks.c
r9881 r10048 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-11- 07 09:07:42$8 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-11-17 23:00:31 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 25 25 /****************************************************************************** 26 myListAddPeak(): A private function which allocates a psArray, if the list 27 argument is NULL, otherwise it adds the peak to that list. 28 XXX EAM : changed the output to psArray 29 XXX EAM : Switched row, col args 30 XXX EAM : NOTE: this was changed in the call, so the new code is consistent 31 *****************************************************************************/ 32 static psArray *myListAddPeak(psArray *list, 33 psS32 row, 34 psS32 col, 35 psF32 counts, 36 pmPeakType type) 37 { 38 psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__); 39 pmPeak *tmpPeak = pmPeakAlloc(col, row, counts, type); 40 41 if (list == NULL) { 42 list = psArrayAllocEmpty(100); 43 } 44 psArrayAdd(list, 100, tmpPeak); 45 psFree (tmpPeak); 46 // XXX EAM : is this free appropriate? (does psArrayAdd increment memory counter?) 47 48 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__); 49 return(list); 26 AddPeak(): A private function which allocates a psArray, if the peaks 27 argument is NULL, otherwise it adds the peak to that array. 28 XXX EAM : row,col now refer to image coords, NOT parent (since this is private) 29 XXX EAM : now also calculates fractional peak positions from 3x3 bicube region 30 *****************************************************************************/ 31 static psArray *AddPeak(psArray *peaks, 32 const psImage *image, 33 psS32 row, 34 psS32 col, 35 pmPeakType type) 36 { 37 psTrace(__func__, 5, "---- begin ----\n"); 38 39 if (peaks == NULL) { 40 peaks = psArrayAllocEmpty(100); 41 } 42 43 // the peak position is in parent coordinates 44 pmPeak *peak = pmPeakAlloc(col + image->col0, row + image->row0, image->data.F32[row][col], type); 45 46 // measure fractional peak position using the 3x3 bicube fit 47 48 // ix,iy must land on image with 1 pixel border 49 int ix = PS_MAX (PS_MIN (col, image->numCols - 2), 1); 50 int iy = PS_MAX (PS_MIN (row, image->numRows - 2), 1); 51 52 // calculate peak position relative to ix,iy 53 psPolynomial2D *bicube = psImageBicubeFit (image, ix + image->col0, iy + image->row0); 54 psPlane min = psImageBicubeMin (bicube); 55 psFree (bicube); 56 57 // if min point is too deviant, use the peak value 58 if ((fabs(min.x) < 1.5) && (fabs(min.y) < 1.5)) { 59 peak->xf = min.x + ix + image->col0; 60 peak->yf = min.y + iy + image->row0; 61 } else { 62 peak->xf = ix; 63 peak->yf = iy; 64 } 65 66 psArrayAdd(peaks, 100, peak); 67 psFree (peak); 68 69 psTrace(__func__, 5, "---- end ----\n"); 70 return(peaks); 50 71 } 51 72 … … 306 327 psArray *list = NULL; 307 328 308 psU32 col0 = image->col0;309 psU32 row0 = image->row0;310 311 //312 329 // Find peaks in row 0 only. 313 //314 330 row = 0; 315 331 tmpRow = getRowVectorFromImage((psImage *) image, row); … … 319 335 for (psU32 i = 0 ; i < row1->n ; i++ ) { 320 336 col = row1->data.U32[i]; 321 // 322 // Determine if pixel (0,0) is a peak. 323 // 337 // is pixel (0,0) is a peak? 324 338 if (col == 0) { 325 339 if ( (image->data.F32[row][col] > image->data.F32[row][col+1]) && … … 328 342 329 343 if (image->data.F32[row][col] > threshold) { 330 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], PM_PEAK_EDGE);344 list = AddPeak(list, image, row, col, PM_PEAK_EDGE); 331 345 } 332 346 } … … 338 352 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 339 353 if (image->data.F32[row][col] > threshold) { 340 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], PM_PEAK_EDGE);354 list = AddPeak(list, image, row, col, PM_PEAK_EDGE); 341 355 } 342 356 } … … 347 361 (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) { 348 362 if (image->data.F32[row][col] > threshold) { 349 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], PM_PEAK_EDGE);363 list = AddPeak(list, image, row, col, PM_PEAK_EDGE); 350 364 } 351 365 } … … 386 400 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 387 401 myType = PM_PEAK_EDGE; 388 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], myType);402 list = AddPeak(list, image, row, col, myType); 389 403 } 390 404 } else if (col < (image->numCols - 1)) { … … 421 435 } 422 436 423 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], myType); 424 425 # if (0) 426 427 psPolynomial2D *bicube = psImageBicubeFit (inSource->pixels, ix, iy); 428 psPlane min = psImageBicubeMin (bicube); 429 peak->xf = min.x; 430 peak->yf = min.y; 431 # endif 437 list = AddPeak(list, image, row, col, myType); 432 438 433 439 } … … 442 448 (image->data.F32[row][col] >= image->data.F32[row+1][col])) { 443 449 myType = PM_PEAK_EDGE; 444 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], myType);450 list = AddPeak(list, image, row, col, myType); 445 451 } 446 452 } else { … … 466 472 (image->data.F32[row][col] > image->data.F32[row][col+1])) { 467 473 if (image->data.F32[row][col] > threshold) { 468 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], PM_PEAK_EDGE);474 list = AddPeak(list, image, row, col, PM_PEAK_EDGE); 469 475 } 470 476 } … … 476 482 (image->data.F32[row][col] >= image->data.F32[row][col+1])) { 477 483 if (image->data.F32[row][col] > threshold) { 478 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], PM_PEAK_EDGE);484 list = AddPeak(list, image, row, col, PM_PEAK_EDGE); 479 485 } 480 486 } … … 485 491 (image->data.F32[row][col] > image->data.F32[row][col-1])) { 486 492 if (image->data.F32[row][col] > threshold) { 487 list = myListAddPeak(list, row + row0, col + col0, image->data.F32[row][col], PM_PEAK_EDGE);493 list = AddPeak(list, image, row, col, PM_PEAK_EDGE); 488 494 } 489 495 }
Note:
See TracChangeset
for help on using the changeset viewer.
