Changeset 3723 for trunk/psModules/src/pmObjects.c
- Timestamp:
- Apr 19, 2005, 1:44:54 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmObjects.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmObjects.c
r3717 r3723 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-04-19 2 2:58:48$7 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-04-19 23:44:54 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 312 312 above the given threshold. Returns a psList containing location (x/y value) 313 313 of all peaks. 314 315 XXX: For multiple type peaks, ensure that each is set. 316 317 XXX: This does not work if image has either a single row, or a single column. 318 *****************************************************************************/ 314 *****************************************************************************/ 319 315 psList *pmFindImagePeaks(const psImage *image, 320 316 psF32 threshold) … … 322 318 PS_IMAGE_CHECK_NULL(image, NULL); 323 319 PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, NULL); 324 if ((image->numRows == 1) || (image->numCols == 1)) {325 psError(PS_ERR_UNKNOWN, true, "Currently, input image must have at least 2 rows and 2 columns.");326 }327 320 psPeakType myPeakClass = PM_PEAK_UNDEF; 328 321 psVector *tmpRow = NULL; … … 332 325 333 326 // 334 // Find peaks in row 0 only. 327 // Special case: a 1-by-1 image. 328 // 329 if ((image->numCols == 1) && (image->numRows == 1)) { 330 if (image->data.F32[row][col] > threshold) { 331 myPeakClass = PM_PEAK_EDGE | PM_PEAK_LONE; 332 list = MyListAddPeak(list, 0, 0, image->data.F32[row][col], myPeakClass); 333 return(list); 334 } else { 335 return(NULL); 336 } 337 } 338 339 // 340 // Find peaks in row 0 only (single-row image). This is a special case since 341 // we can not test data at image->data.F32[row+1][...]) 342 // 343 if (image->numRows == 1) { 344 row = 0; 345 tmpRow = p_psGetRowVectorFromImage((psImage *) image, row); 346 psVector *row1 = pmFindVectorPeaks(tmpRow, threshold); 347 for (psU32 i = 0 ; i < row1->n ; i++ ) { 348 col = row1->data.U32[i]; 349 // 350 // Determine if pixel (0,0) is a peak. 351 // 352 if (col == 0) { 353 if ( (image->data.F32[row][col] > threshold) && 354 (image->data.F32[row][col] > image->data.F32[row][col+1])) { 355 myPeakClass = PM_PEAK_EDGE | PM_PEAK_LONE; 356 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 357 } 358 } else if (col < (image->numCols - 1)) { 359 360 if ( (image->data.F32[row][col] > threshold) && 361 (image->data.F32[row][col] >= image->data.F32[row][col-1]) && 362 (image->data.F32[row][col] > image->data.F32[row][col+1])) { 363 myPeakClass = PM_PEAK_EDGE; 364 365 if (image->data.F32[row][col] > image->data.F32[row][col-1]) { 366 myPeakClass|= PM_PEAK_LONE; 367 } else { 368 myPeakClass|= PM_PEAK_FLAT; 369 } 370 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 371 } 372 373 } else if (col == (image->numCols - 1)) { 374 if ( (image->data.F32[row][col] > threshold) && 375 (image->data.F32[row][col] >= image->data.F32[row][col-1])) { 376 myPeakClass = PM_PEAK_EDGE; 377 378 if (image->data.F32[row][col] > image->data.F32[row][col-1]) { 379 myPeakClass|= PM_PEAK_LONE; 380 } else { 381 myPeakClass|= PM_PEAK_FLAT; 382 } 383 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 384 } 385 } else { 386 psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range."); 387 } 388 389 } 390 // 391 // We exit here since this is a single-row image. 392 // 393 // XXX: Why are we not getting memory leak errors? 394 // 395 // 396 // psFree(tmpRow); 397 // psFree(row1); 398 // 399 return(list); 400 } 401 402 // 403 // Find peaks in col 0 only (single-col image). This is a special case since 404 // we can not test data at image->data.F32[...][col+1]) 405 // 406 if (image->numCols == 1) { 407 col = 0; 408 psVector *tmpCol = p_psGetColVectorFromImage((psImage *) image, col); 409 psVector *col1 = pmFindVectorPeaks(tmpCol, threshold); 410 for (psU32 i = 0 ; i < col1->n ; i++ ) { 411 row = col1->data.U32[i]; 412 // 413 // Determine if pixel (0,0) is a peak. 414 // 415 if (row == 0) { 416 if ( (image->data.F32[row][col] > threshold) && 417 (image->data.F32[row][col] > image->data.F32[row+1][col])) { 418 myPeakClass = PM_PEAK_EDGE | PM_PEAK_LONE; 419 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 420 } 421 } else if (row < (image->numRows - 1)) { 422 423 if ( (image->data.F32[row][col] > threshold) && 424 (image->data.F32[row][col] >= image->data.F32[row-1][col]) && 425 (image->data.F32[row][col] > image->data.F32[row+1][col])) { 426 myPeakClass = PM_PEAK_EDGE; 427 428 if (image->data.F32[row][col] > image->data.F32[row-1][col]) { 429 myPeakClass|= PM_PEAK_LONE; 430 } else { 431 myPeakClass|= PM_PEAK_FLAT; 432 } 433 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 434 } 435 436 } else if (row == (image->numRows - 1)) { 437 if ( (image->data.F32[row][col] > threshold) && 438 (image->data.F32[row][col] >= image->data.F32[row-1][col])) { 439 myPeakClass = PM_PEAK_EDGE; 440 441 if (image->data.F32[row][col] > image->data.F32[row-1][col]) { 442 myPeakClass|= PM_PEAK_LONE; 443 } else { 444 myPeakClass|= PM_PEAK_FLAT; 445 } 446 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 447 } 448 } else { 449 psError(PS_ERR_UNKNOWN, true, "peak specified outside valid row range."); 450 } 451 452 } 453 // 454 // We exit here since this is a single-column image. 455 // 456 // XXX: free tmpRow col1? 457 // 458 return(list); 459 } 460 461 // 462 // Find peaks in row 0 only (multi-row image). 335 463 // 336 464 row = 0; … … 392 520 psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range."); 393 521 } 394 }395 //396 // Exit if this image has a single row.397 //398 if (image->numRows == 1) {399 return(list);400 522 } 401 523
Note:
See TracChangeset
for help on using the changeset viewer.
