Changeset 3717
- Timestamp:
- Apr 19, 2005, 12:58:48 PM (21 years ago)
- Location:
- trunk/psModules
- Files:
-
- 2 edited
-
src/pmObjects.c (modified) (9 diffs)
-
test/tst_pmObjects01.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmObjects.c
r3701 r3717 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-04-1 4 03:27:50$7 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-04-19 22:58:48 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 45 45 tmp->y = 0.0; 46 46 tmp->Sx = 0.0; 47 tmp->S x= 0.0;47 tmp->Sy = 0.0; 48 48 tmp->Sxy = 0.0; 49 49 tmp->Sum = 0.0; … … 325 325 psError(PS_ERR_UNKNOWN, true, "Currently, input image must have at least 2 rows and 2 columns."); 326 326 } 327 psPeakType myPeakClass = PM_PEAK_UNDEF; 327 328 psVector *tmpRow = NULL; 328 329 psU32 col = 0; … … 343 344 // 344 345 if (col == 0) { 345 if ( (image->data.F32[row][col] > image->data.F32[row][col+1]) && 346 if ( (image->data.F32[row][col] > threshold) && 347 (image->data.F32[row][col] > image->data.F32[row][col+1]) && 346 348 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 347 349 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 348 if (image->data.F32[row][col] > threshold) { 349 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 350 myPeakClass = PM_PEAK_EDGE; 351 if (image->data.F32[row][col] > image->data.F32[row+1][col+1]) { 352 myPeakClass|= PM_PEAK_LONE; 353 } else { 354 myPeakClass|= PM_PEAK_FLAT; 350 355 } 356 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 351 357 } 352 358 } else if (col < (image->numCols - 1)) { 353 if ( (image->data.F32[row][col] >= image->data.F32[row][col-1]) && 359 if ( (image->data.F32[row][col] > threshold) && 360 (image->data.F32[row][col] >= image->data.F32[row][col-1]) && 354 361 (image->data.F32[row][col] > image->data.F32[row][col+1]) && 355 362 (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) && 356 363 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 357 364 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 358 if (image->data.F32[row][col] > threshold) { 359 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 365 366 myPeakClass = PM_PEAK_EDGE; 367 if ( (image->data.F32[row][col] > image->data.F32[row][col-1]) && 368 (image->data.F32[row][col] > image->data.F32[row+1][col-1]) && 369 (image->data.F32[row][col] > image->data.F32[row+1][col+1])) { 370 myPeakClass|= PM_PEAK_LONE; 371 } else { 372 myPeakClass|= PM_PEAK_FLAT; 360 373 } 374 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 361 375 } 362 376 363 377 } else if (col == (image->numCols - 1)) { 364 if ( (image->data.F32[row][col] >= image->data.F32[row][col-1]) && 378 if ( (image->data.F32[row][col] > threshold) && 379 (image->data.F32[row][col] >= image->data.F32[row][col-1]) && 365 380 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 366 381 (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) { 367 if (image->data.F32[row][col] > threshold) { 368 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 382 myPeakClass = PM_PEAK_EDGE; 383 if ( (image->data.F32[row][col] > image->data.F32[row][col-1]) && 384 (image->data.F32[row][col] > image->data.F32[row+1][col-1])) { 385 myPeakClass|= PM_PEAK_LONE; 386 } else { 387 myPeakClass|= PM_PEAK_FLAT; 369 388 } 389 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 370 390 } 371 372 391 } else { 373 psError(PS_ERR_UNKNOWN, true, "peak specified valid column range.");392 psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range."); 374 393 } 375 394 } … … 390 409 // Step through all local peaks in this row. 391 410 for (psU32 i = 0 ; i < row1->n ; i++ ) { 392 psPeakType myType = PM_PEAK_UNDEF;393 411 col = row1->data.U32[i]; 394 412 395 413 if (col == 0) { 396 414 // If col==0, then we can not read col-1 pixels 397 if ((image->data.F32[row][col] > image->data.F32[row-1][col]) && 415 if ((image->data.F32[row][col] > threshold) && 416 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 398 417 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) && 399 418 (image->data.F32[row][col] >= image->data.F32[row][col+1]) && 400 419 (image->data.F32[row][col] >= image->data.F32[row+1][col]) && 401 420 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 402 myType = PM_PEAK_EDGE; 403 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType); 421 422 myPeakClass = PM_PEAK_EDGE; 423 if ((image->data.F32[row][col] > image->data.F32[row-1][col+1]) && 424 (image->data.F32[row][col] > image->data.F32[row][col+1]) && 425 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 426 (image->data.F32[row][col] > image->data.F32[row+1][col+1])) { 427 myPeakClass|= PM_PEAK_LONE; 428 } else { 429 myPeakClass|= PM_PEAK_FLAT; 430 } 431 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 404 432 } 405 433 } else if (col < (image->numCols - 1)) { 406 434 // This is an interior pixel 407 if ((image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 435 if ((image->data.F32[row][col] > threshold) && 436 (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 408 437 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 409 438 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) && … … 413 442 (image->data.F32[row][col] >= image->data.F32[row+1][col]) && 414 443 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 415 if (image->data.F32[row][col] > threshold) { 416 if ((image->data.F32[row][col] > image->data.F32[row-1][col-1]) && 417 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 418 (image->data.F32[row][col] > image->data.F32[row-1][col+1]) && 419 (image->data.F32[row][col] > image->data.F32[row][col-1]) && 420 (image->data.F32[row][col] > image->data.F32[row][col+1]) && 421 (image->data.F32[row][col] > image->data.F32[row+1][col-1]) && 422 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 423 (image->data.F32[row][col] > image->data.F32[row+1][col+1])) { 424 myType = PM_PEAK_LONE; 425 } 426 427 if ((image->data.F32[row][col] == image->data.F32[row-1][col-1]) || 428 (image->data.F32[row][col] == image->data.F32[row-1][col]) || 429 (image->data.F32[row][col] == image->data.F32[row-1][col+1]) || 430 (image->data.F32[row][col] == image->data.F32[row][col-1]) || 431 (image->data.F32[row][col] == image->data.F32[row][col+1]) || 432 (image->data.F32[row][col] == image->data.F32[row+1][col-1]) || 433 (image->data.F32[row][col] == image->data.F32[row+1][col]) || 434 (image->data.F32[row][col] == image->data.F32[row+1][col+1])) { 435 myType = PM_PEAK_FLAT; 436 } 437 438 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType); 444 445 if ((image->data.F32[row][col] > image->data.F32[row-1][col-1]) && 446 (image->data.F32[row][col] > image->data.F32[row-1][col+1]) && 447 (image->data.F32[row][col] > image->data.F32[row][col+1]) && 448 (image->data.F32[row][col] > image->data.F32[row+1][col-1]) && 449 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 450 (image->data.F32[row][col] > image->data.F32[row+1][col+1])) { 451 myPeakClass = PM_PEAK_LONE; 452 } else { 453 myPeakClass = PM_PEAK_FLAT; 439 454 } 455 456 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 440 457 } 441 458 } else if (col == (image->numCols - 1)) { 442 459 // If col==numCols - 1, then we can not read col+1 pixels 443 if ((image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 460 if ((image->data.F32[row][col] > threshold) && 461 (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 444 462 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 445 463 (image->data.F32[row][col] > image->data.F32[row][col-1]) && … … 447 465 (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) && 448 466 (image->data.F32[row][col] >= image->data.F32[row+1][col])) { 449 myType = PM_PEAK_EDGE; 450 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType); 467 468 myPeakClass = PM_PEAK_EDGE; 469 if ((image->data.F32[row][col] > image->data.F32[row-1][col-1]) && 470 (image->data.F32[row][col] > image->data.F32[row][col+1]) && 471 (image->data.F32[row][col] > image->data.F32[row+1][col-1]) && 472 (image->data.F32[row][col] > image->data.F32[row+1][col])) { 473 myPeakClass|= PM_PEAK_LONE; 474 } else { 475 myPeakClass|= PM_PEAK_FLAT; 476 } 477 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 451 478 } 452 479 } else { 453 psError(PS_ERR_UNKNOWN, true, "peak specified valid column range.");480 psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range."); 454 481 } 455 456 482 } 457 483 } … … 466 492 col = row1->data.U32[i]; 467 493 if (col == 0) { 468 if ( (image->data.F32[row][col] > image->data.F32[row-1][col]) && 494 if ( (image->data.F32[row][col] > threshold) && 495 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 469 496 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) && 470 497 (image->data.F32[row][col] > image->data.F32[row][col+1])) { 471 if (image->data.F32[row][col] > threshold) { 472 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 498 499 myPeakClass = PM_PEAK_EDGE; 500 if (image->data.F32[row][col] > image->data.F32[row-1][col+1]) { 501 myPeakClass|= PM_PEAK_LONE; 502 } else { 503 myPeakClass|= PM_PEAK_FLAT; 473 504 } 505 506 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 474 507 } 475 508 } else if (col < (image->numCols - 1)) { 476 if ( (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 509 if ( (image->data.F32[row][col] > threshold) && 510 (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 477 511 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 478 512 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) && 479 513 (image->data.F32[row][col] > image->data.F32[row][col-1]) && 480 514 (image->data.F32[row][col] >= image->data.F32[row][col+1])) { 481 if (image->data.F32[row][col] > threshold) { 482 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 515 516 myPeakClass = PM_PEAK_EDGE; 517 if ( (image->data.F32[row][col] > image->data.F32[row-1][col-1]) && 518 (image->data.F32[row][col] > image->data.F32[row-1][col+1]) && 519 (image->data.F32[row][col] > image->data.F32[row][col+1])) { 520 myPeakClass|= PM_PEAK_LONE; 521 } else { 522 myPeakClass|= PM_PEAK_FLAT; 483 523 } 524 525 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 484 526 } 485 527 486 528 } else if (col == (image->numCols - 1)) { 487 if ( (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 529 if ( (image->data.F32[row][col] > threshold) && 530 (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 488 531 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 489 532 (image->data.F32[row][col] > image->data.F32[row][col-1])) { 490 if (image->data.F32[row][col] > threshold) { 491 list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE); 533 534 myPeakClass = PM_PEAK_EDGE; 535 if (image->data.F32[row][col] > image->data.F32[row-1][col-1]) { 536 myPeakClass|= PM_PEAK_LONE; 537 } else { 538 myPeakClass|= PM_PEAK_FLAT; 492 539 } 540 541 list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass); 493 542 } 494 543 } else { … … 600 649 psS32 SubImageCenterRow = peak->y; 601 650 psS32 SubImageCenterCol = peak->x; 602 psS32 SubImageStartRow = SubImageCenterRow - outerRadiusS32;603 psS32 SubImageEndRow = SubImageCenterRow + outerRadiusS32;604 psS32 SubImageStartCol = SubImageCenterCol - outerRadiusS32;605 psS32 SubImageEndCol = SubImageCenterCol + outerRadiusS32;651 psS32 SubImageStartRow = PS_MAX(SubImageCenterRow - outerRadiusS32, 0); 652 psS32 SubImageEndRow = PS_MIN(SubImageCenterRow + outerRadiusS32, image->numRows - 1); 653 psS32 SubImageStartCol = PS_MAX(SubImageCenterCol - outerRadiusS32, 0); 654 psS32 SubImageEndCol = PS_MIN(SubImageCenterCol + outerRadiusS32, image->numCols - 1); 606 655 // AnulusWidth == number of pixels width in the annulus. We add one since 607 656 // the pixels at the inner AND outher radius are included. -
trunk/psModules/test/tst_pmObjects01.c
r3697 r3717 19 19 * abd never deallocate, no error is generated. 20 20 * 21 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $22 * @date $Date: 2005-04-1 4 00:16:39$21 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2005-04-19 22:58:48 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 62 62 int main(int argc, char* argv[]) 63 63 { 64 return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv); 64 // return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv); 65 test02(); 65 66 } 66 67 … … 73 74 psTraceSetLevel(".", 0); 74 75 75 psPeak *tmpPeak = pmPeakAlloc(0, 0, 0.0, PM_PEAK_UNDEF); 76 printf("Testing pmPeakAlloc()...\n"); 77 psPeak *tmpPeak = pmPeakAlloc(1, 2, 3.0, PM_PEAK_LONE); 76 78 if (tmpPeak == NULL) { 77 79 printf("TEST ERROR: pmPeakAlloc() returned a NULL psPeak\n"); 78 80 testStatus = false; 79 } 80 // XXX: Test that values were set properly. 81 } else { 82 if (tmpPeak->x != 1) { 83 printf("TEST ERROR: pmPeakAlloc() improperly set psPeak->x\n"); 84 testStatus = false; 85 } 86 if (tmpPeak->y != 2) { 87 printf("TEST ERROR: pmPeakAlloc() improperly set psPeak->y\n"); 88 testStatus = false; 89 } 90 if (tmpPeak->counts != 3.0) { 91 printf("TEST ERROR: pmPeakAlloc() improperly set psPeak->counts\n"); 92 testStatus = false; 93 } 94 if (tmpPeak->class != PM_PEAK_LONE) { 95 printf("TEST ERROR: pmPeakAlloc() improperly set psPeak->class\n"); 96 testStatus = false; 97 } 98 } 81 99 psFree(tmpPeak); 82 100 101 printf("Testing pmMomentsAlloc()...\n"); 83 102 psMoments *tmpMoments = pmMomentsAlloc(); 84 103 if (tmpMoments == NULL) { 85 104 printf("TEST ERROR: pmMomentsAlloc() returned a NULL psMoments\n"); 86 105 testStatus = false; 106 } else { 107 if ((tmpMoments->x != 0.0) || 108 (tmpMoments->y != 0.0) || 109 (tmpMoments->Sx != 0.0) || 110 (tmpMoments->Sy != 0.0) || 111 (tmpMoments->Sxy != 0.0) || 112 (tmpMoments->Sum != 0.0) || 113 (tmpMoments->Peak != 0.0) || 114 (tmpMoments->Sky != 0.0) || 115 (tmpMoments->nPixels != 0)) { 116 printf("TEST ERROR: pmMomentsAlloc() did not properly initialize the psMoments structure.\n"); 117 testStatus = false; 118 } 87 119 } 88 120 psFree(tmpMoments); 89 121 90 // XXX: Must test this with variety of models, and verify param length.122 printf("Testing pmModelAlloc(PS_MODEL_GAUSS)...\n"); 91 123 psModel *tmpModel = pmModelAlloc(PS_MODEL_GAUSS); 92 124 if (tmpModel == NULL) { 93 printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n"); 94 testStatus = false; 95 } 96 // XXX: Test that values were set properly. 125 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) returned a NULL psModel\n"); 126 testStatus = false; 127 } else { 128 if (tmpModel->Nparams != 7) { 129 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 130 testStatus = false; 131 } else { 132 for (psS32 i = 0 ; i < 7 ; i++) { 133 if ((tmpModel->params[i] != 0.0) || 134 (tmpModel->dparams[i] != 0.0)) { 135 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 136 testStatus = false; 137 } 138 } 139 } 140 } 97 141 psFree(tmpModel); 98 142 99 // XXX: Must test this with variety of models, and verify param length.143 printf("Testing pmModelAlloc(PS_MODEL_PGAUSS)...\n"); 100 144 tmpModel = pmModelAlloc(PS_MODEL_PGAUSS); 101 145 if (tmpModel == NULL) { 102 printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n"); 103 testStatus = false; 104 } 105 // XXX: Test that values were set properly. 146 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) returned a NULL psModel\n"); 147 testStatus = false; 148 } else { 149 if (tmpModel->Nparams != 7) { 150 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 151 testStatus = false; 152 } else { 153 for (psS32 i = 0 ; i < 7 ; i++) { 154 if ((tmpModel->params[i] != 0.0) || 155 (tmpModel->dparams[i] != 0.0)) { 156 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 157 testStatus = false; 158 } 159 } 160 } 161 } 106 162 psFree(tmpModel); 107 163 108 // XXX: Must test this with variety of models, and verify param length.164 printf("Testing pmModelAlloc(PS_MODEL_TWIST_GAUSS)...\n"); 109 165 tmpModel = pmModelAlloc(PS_MODEL_TWIST_GAUSS); 110 166 if (tmpModel == NULL) { 111 printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n"); 112 testStatus = false; 113 } 114 // XXX: Test that values were set properly. 167 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) returned a NULL psModel\n"); 168 testStatus = false; 169 } else { 170 if (tmpModel->Nparams != 11) { 171 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 172 testStatus = false; 173 } else { 174 for (psS32 i = 0 ; i < 11 ; i++) { 175 if ((tmpModel->params[i] != 0.0) || 176 (tmpModel->dparams[i] != 0.0)) { 177 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 178 testStatus = false; 179 } 180 } 181 } 182 } 115 183 psFree(tmpModel); 116 184 117 // XXX: Must test this with variety of models, and verify param length.185 printf("Testing pmModelAlloc(PS_MODEL_WAUSS)...\n"); 118 186 tmpModel = pmModelAlloc(PS_MODEL_WAUSS); 119 187 if (tmpModel == NULL) { 120 printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n"); 121 testStatus = false; 122 } 123 // XXX: Test that values were set properly. 188 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) returned a NULL psModel\n"); 189 testStatus = false; 190 } else { 191 if (tmpModel->Nparams != 9) { 192 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 193 testStatus = false; 194 } else { 195 for (psS32 i = 0 ; i < 9 ; i++) { 196 if ((tmpModel->params[i] != 0.0) || 197 (tmpModel->dparams[i] != 0.0)) { 198 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 199 testStatus = false; 200 } 201 } 202 } 203 } 124 204 psFree(tmpModel); 125 205 126 // XXX: Must test this with variety of models, and verify param length.206 printf("Testing pmModelAlloc(PS_MODEL_SERSIC)...\n"); 127 207 tmpModel = pmModelAlloc(PS_MODEL_SERSIC); 128 208 if (tmpModel == NULL) { 129 printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n"); 130 testStatus = false; 131 } 132 // XXX: Test that values were set properly. 209 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) returned a NULL psModel\n"); 210 testStatus = false; 211 } else { 212 if (tmpModel->Nparams != 8) { 213 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 214 testStatus = false; 215 } else { 216 for (psS32 i = 0 ; i < 8 ; i++) { 217 if ((tmpModel->params[i] != 0.0) || 218 (tmpModel->dparams[i] != 0.0)) { 219 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) did not ininitialize the params/dparams array to 0.0.\n"); 220 testStatus = false; 221 } 222 } 223 } 224 } 133 225 psFree(tmpModel); 134 226 135 // XXX: Must test this with variety of models, and verify param length.227 printf("Testing pmModelAlloc(PS_MODEL_SERSIC_CORE)...\n"); 136 228 tmpModel = pmModelAlloc(PS_MODEL_SERSIC_CORE); 137 229 if (tmpModel == NULL) { 138 printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n"); 139 testStatus = false; 140 } 141 // XXX: Test that values were set properly. 230 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) returned a NULL psModel\n"); 231 testStatus = false; 232 } else { 233 if (tmpModel->Nparams != 12) { 234 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 235 testStatus = false; 236 } else { 237 for (psS32 i = 0 ; i < 12 ; i++) { 238 if ((tmpModel->params[i] != 0.0) || 239 (tmpModel->dparams[i] != 0.0)) { 240 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) did not ininitialize the params/dparams array to 0.0.\n"); 241 testStatus = false; 242 } 243 } 244 } 245 } 142 246 psFree(tmpModel); 143 247 … … 152 256 } 153 257 154 #define VECTOR_SIZE 10 258 /****************************************************************************** 259 test01(): we first test pmFindVectorPeaks() with a variety of bad input 260 parameters. Then we test it with a simple vector both 1- and multi-elements. 261 *****************************************************************************/ 262 #define TST01_VECTOR_LENGTH 10 155 263 bool test_pmFindVectorPeaks(int n) 156 264 { … … 174 282 testStatus = false; 175 283 } else { 176 177 284 if (outData->n != 1) { 178 285 printf("TEST ERROR: outData->n is %d\n", outData->n); … … 315 422 } 316 423 317 318 424 psFree(inData); 319 425 return(testStatus); 320 426 } 321 322 427 323 428 int test01( void ) … … 325 430 bool testStatus = true; 326 431 psVector *tmpVec = NULL; 327 psVector *tmpVecF64 = psVectorAlloc( 10, PS_TYPE_F64);432 psVector *tmpVecF64 = psVectorAlloc(TST01_VECTOR_LENGTH, PS_TYPE_F64); 328 433 psVector *tmpVecEmpty = psVectorAlloc(0, PS_TYPE_F32); 329 434 … … 357 462 } 358 463 testStatus&= test_pmFindVectorPeaks(1); 359 testStatus&= test_pmFindVectorPeaks( VECTOR_SIZE);464 testStatus&= test_pmFindVectorPeaks(TST01_VECTOR_LENGTH); 360 465 361 466 psFree(tmpVecF64); … … 364 469 } 365 470 366 // XXX: Add tests for the PEAK_TYPE. 367 // XXX: Add interior peaks, edge peaks, and flat peaks. 471 /****************************************************************************** 472 test02(): 473 // XXX: Must test flat peaks. 474 // XXX: test 1-by-n and n-by-1 images. 475 *****************************************************************************/ 476 #define TST02_NUM_ROWS 5 477 #define TST02_NUM_COLS 5 368 478 bool test_pmFindImagePeaks(int numRows, int numCols) 369 479 { 370 480 printf("-------------- Calling test_pmFindVectorPeaks on an %d-by-%d image. --------------\n", numRows, numCols); 481 if ((numRows < 4) || (numCols < 4)) { 482 printf("WARNING: Don't call this test with a smaller than 4-by-4 image.\n"); 483 return(true); 484 } 371 485 bool testStatus = true; 372 486 psImage *inData = psImageAlloc(numCols, numRows, PS_TYPE_F32); … … 374 488 375 489 // 376 // Test first pixel peak.490 // Initialize test image. 377 491 // 378 492 for (psS32 i = 0 ; i < numRows ; i++) { … … 381 495 } 382 496 } 497 // 498 // Set corner and center pixels as peaks. 499 // 383 500 inData->data.F32[0][0] = PS_SQR(numRows) + PS_SQR(numCols); 384 501 inData->data.F32[0][numCols-1] = PS_SQR(numRows) + PS_SQR(numCols); 385 502 inData->data.F32[numRows-1][0] = PS_SQR(numRows) + PS_SQR(numCols); 386 503 inData->data.F32[numRows-1][numCols-1] = PS_SQR(numRows) + PS_SQR(numCols); 504 inData->data.F32[numRows/2][numCols/2] = PS_SQR(numRows) + PS_SQR(numCols); 505 506 // 507 // Print image. 508 // 387 509 for (psS32 i = 0 ; i < numRows ; i++) { 388 510 for (psS32 j = 0 ; j < numCols ; j++) { … … 392 514 } 393 515 516 // 517 // Call pmFindImagePeaks() with a threshold of 0.0. 518 // 394 519 outData = pmFindImagePeaks(inData, 0.0); 395 520 … … 398 523 testStatus = false; 399 524 } else { 400 if (outData->size != 4) {401 printf("TEST ERROR: pmFindImagePeaks found only%d peaks (should be 4)\n", outData->size);525 if (outData->size != 5) { 526 printf("TEST ERROR: pmFindImagePeaks found %d peaks (should be 4)\n", outData->size); 402 527 testStatus = false; 403 528 } … … 406 531 while (tmpPeakLE != NULL) { 407 532 psPeak *tmpPeak = (psPeak *) tmpPeakLE->data; 408 if (((tmpPeak->x == 0) || (tmpPeak->x == numRows-1)) && 409 ((tmpPeak->y == 0) || (tmpPeak->y == numCols-1))) {} 410 else { 411 printf("TEST ERROR: Peak at (%d, %d) (%f)\n", tmpPeak->x, tmpPeak->y, tmpPeak->counts); 533 if (((tmpPeak->x == 0) && (tmpPeak->y == 0)) || 534 ((tmpPeak->x == 0) && (tmpPeak->y == numRows-1)) || 535 ((tmpPeak->x == numCols-1) && (tmpPeak->y == 0)) || 536 ((tmpPeak->x == numCols-1) && (tmpPeak->y == numRows-1))) { 537 if (!(tmpPeak->class & PM_PEAK_LONE) || 538 !(tmpPeak->class & PM_PEAK_EDGE)) { 539 printf("TEST ERROR: peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class); 540 testStatus = false; 541 } 542 } else if ((tmpPeak->x == numCols/2) && (tmpPeak->y == numRows/2)) { 543 if (!(tmpPeak->class & PM_PEAK_LONE)) { 544 printf("TEST ERROR: peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class); 545 testStatus = false; 546 } 547 } else { 548 printf("TEST ERROR: Peak at (%d, %d) (%f)\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts); 412 549 testStatus = false; 413 550 } 551 414 552 tmpPeakLE = tmpPeakLE->next; 415 553 } … … 421 559 } 422 560 423 424 561 int test02( void ) 425 562 { 426 563 bool testStatus = true; 427 564 psList *tmpList = NULL; 428 psImage *tmpImageF64 = psImageAlloc( 10, 10, PS_TYPE_F64);565 psImage *tmpImageF64 = psImageAlloc(TST02_NUM_ROWS, TST02_NUM_COLS, PS_TYPE_F64); 429 566 psImage *tmpImageEmpty = psImageAlloc(0, 0, PS_TYPE_F32); 430 567 … … 461 598 // testStatus&= test_pmFindImagePeaks(2, 5); 462 599 // testStatus&= test_pmFindImagePeaks(5, 2); 463 testStatus&= test_pmFindImagePeaks(10, 10); 600 // HEY 601 testStatus&= test_pmFindImagePeaks(TST02_NUM_ROWS, TST02_NUM_COLS); 602 testStatus&= test_pmFindImagePeaks(2*TST02_NUM_ROWS, TST02_NUM_COLS); 603 testStatus&= test_pmFindImagePeaks(TST02_NUM_ROWS, 2*TST02_NUM_COLS); 464 604 465 605
Note:
See TracChangeset
for help on using the changeset viewer.
