Changeset 4954 for trunk/psphot/src/pmObjects_EAM.c
- Timestamp:
- Sep 6, 2005, 5:33:01 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/pmObjects_EAM.c (modified) (51 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/pmObjects_EAM.c
r4950 r4954 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-09-0 6 08:05:08$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-09-07 03:33:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 66 66 pmModelAlloc(): Allocate the pmModel structure, along with its parameters, 67 67 and initialize the type member. Initialize the params to 0.0. 68 XXX EAM: changing params and dparams to psVector 69 XXX EAM: simplifying code with psModelParameterCount 68 XXX EAM: simplifying code with pmModelParameterCount 70 69 *****************************************************************************/ 71 70 pmModel *pmModelAlloc(pmModelType type) … … 76 75 tmp->chisq = 0.0; 77 76 tmp->nIter = 0; 78 psS32 Nparams = p sModelParameterCount (type);77 psS32 Nparams = pmModelParameterCount (type); 79 78 if (Nparams == 0) { 80 psError(PS_ERR_UNKNOWN, true, "Undefined p sModelType");79 psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType"); 81 80 return(NULL); 82 81 } … … 167 166 // 168 167 if ((vector->data.F32[0] > vector->data.F32[1]) && 169 (vector->data.F32[0] > threshold)) {168 (vector->data.F32[0] > threshold)) { 170 169 count++; 171 170 } … … 176 175 for (psU32 i = 1; i < n-1 ; i++) { 177 176 if ((vector->data.F32[i] > vector->data.F32[i-1]) && 178 (vector->data.F32[i] > vector->data.F32[i+1]) &&179 (vector->data.F32[i] > threshold)) {177 (vector->data.F32[i] > vector->data.F32[i+1]) && 178 (vector->data.F32[i] > threshold)) { 180 179 count++; 181 180 } … … 186 185 // 187 186 if ((vector->data.F32[n-1] > vector->data.F32[n-2]) && 188 (vector->data.F32[n-1] > threshold)) {187 (vector->data.F32[n-1] > threshold)) { 189 188 count++; 190 189 } … … 201 200 // 202 201 if ((vector->data.F32[0] > vector->data.F32[1]) && 203 (vector->data.F32[0] > threshold)) {202 (vector->data.F32[0] > threshold)) { 204 203 tmpVector->data.U32[count++] = 0; 205 204 } … … 210 209 for (psU32 i = 1; i < (n-1) ; i++) { 211 210 if ((vector->data.F32[i] > vector->data.F32[i-1]) && 212 (vector->data.F32[i] > vector->data.F32[i+1]) &&213 (vector->data.F32[i] > threshold)) {211 (vector->data.F32[i] > vector->data.F32[i+1]) && 212 (vector->data.F32[i] > threshold)) { 214 213 tmpVector->data.U32[count++] = i; 215 214 } … … 220 219 // 221 220 if ((vector->data.F32[n-1] > vector->data.F32[n-2]) && 222 (vector->data.F32[n-1] > threshold)) {221 (vector->data.F32[n-1] > threshold)) { 223 222 tmpVector->data.U32[count++] = n-1; 224 223 } … … 319 318 if (col == 0) { 320 319 if ( (image->data.F32[row][col] > image->data.F32[row][col+1]) && 321 (image->data.F32[row][col] > image->data.F32[row+1][col]) &&322 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {320 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 321 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 323 322 324 323 if (image->data.F32[row][col] > threshold) { … … 328 327 } else if (col < (image->numCols - 1)) { 329 328 if ( (image->data.F32[row][col] >= image->data.F32[row][col-1]) && 330 (image->data.F32[row][col] > image->data.F32[row][col+1]) &&331 (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&332 (image->data.F32[row][col] > image->data.F32[row+1][col]) &&333 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {329 (image->data.F32[row][col] > image->data.F32[row][col+1]) && 330 (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) && 331 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 332 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 334 333 if (image->data.F32[row][col] > threshold) { 335 334 list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE); … … 339 338 } else if (col == (image->numCols - 1)) { 340 339 if ( (image->data.F32[row][col] >= image->data.F32[row][col-1]) && 341 (image->data.F32[row][col] > image->data.F32[row+1][col]) &&342 (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) {340 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 341 (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) { 343 342 if (image->data.F32[row][col] > threshold) { 344 343 list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE); … … 375 374 // If col==0, then we can not read col-1 pixels 376 375 if ((image->data.F32[row][col] > image->data.F32[row-1][col]) && 377 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&378 (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&379 (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&380 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {376 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) && 377 (image->data.F32[row][col] >= image->data.F32[row][col+1]) && 378 (image->data.F32[row][col] >= image->data.F32[row+1][col]) && 379 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 381 380 myType = PM_PEAK_EDGE; 382 381 list = myListAddPeak(list, row, col, image->data.F32[row][col], myType); … … 385 384 // This is an interior pixel 386 385 if ((image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 387 (image->data.F32[row][col] > image->data.F32[row-1][col]) &&388 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&389 (image->data.F32[row][col] > image->data.F32[row][col-1]) &&390 (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&391 (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&392 (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&393 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {386 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 387 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) && 388 (image->data.F32[row][col] > image->data.F32[row][col-1]) && 389 (image->data.F32[row][col] >= image->data.F32[row][col+1]) && 390 (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) && 391 (image->data.F32[row][col] >= image->data.F32[row+1][col]) && 392 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 394 393 if (image->data.F32[row][col] > threshold) { 395 394 if ((image->data.F32[row][col] > image->data.F32[row-1][col-1]) && 396 (image->data.F32[row][col] > image->data.F32[row-1][col]) &&397 (image->data.F32[row][col] > image->data.F32[row-1][col+1]) &&398 (image->data.F32[row][col] > image->data.F32[row][col-1]) &&399 (image->data.F32[row][col] > image->data.F32[row][col+1]) &&400 (image->data.F32[row][col] > image->data.F32[row+1][col-1]) &&401 (image->data.F32[row][col] > image->data.F32[row+1][col]) &&402 (image->data.F32[row][col] > image->data.F32[row+1][col+1])) {395 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 396 (image->data.F32[row][col] > image->data.F32[row-1][col+1]) && 397 (image->data.F32[row][col] > image->data.F32[row][col-1]) && 398 (image->data.F32[row][col] > image->data.F32[row][col+1]) && 399 (image->data.F32[row][col] > image->data.F32[row+1][col-1]) && 400 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 401 (image->data.F32[row][col] > image->data.F32[row+1][col+1])) { 403 402 myType = PM_PEAK_LONE; 404 403 } 405 404 406 405 if ((image->data.F32[row][col] == image->data.F32[row-1][col-1]) || 407 (image->data.F32[row][col] == image->data.F32[row-1][col]) ||408 (image->data.F32[row][col] == image->data.F32[row-1][col+1]) ||409 (image->data.F32[row][col] == image->data.F32[row][col-1]) ||410 (image->data.F32[row][col] == image->data.F32[row][col+1]) ||411 (image->data.F32[row][col] == image->data.F32[row+1][col-1]) ||412 (image->data.F32[row][col] == image->data.F32[row+1][col]) ||413 (image->data.F32[row][col] == image->data.F32[row+1][col+1])) {406 (image->data.F32[row][col] == image->data.F32[row-1][col]) || 407 (image->data.F32[row][col] == image->data.F32[row-1][col+1]) || 408 (image->data.F32[row][col] == image->data.F32[row][col-1]) || 409 (image->data.F32[row][col] == image->data.F32[row][col+1]) || 410 (image->data.F32[row][col] == image->data.F32[row+1][col-1]) || 411 (image->data.F32[row][col] == image->data.F32[row+1][col]) || 412 (image->data.F32[row][col] == image->data.F32[row+1][col+1])) { 414 413 myType = PM_PEAK_FLAT; 415 414 } … … 421 420 // If col==numCols - 1, then we can not read col+1 pixels 422 421 if ((image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 423 (image->data.F32[row][col] > image->data.F32[row-1][col]) &&424 (image->data.F32[row][col] > image->data.F32[row][col-1]) &&425 (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&426 (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&427 (image->data.F32[row][col] >= image->data.F32[row+1][col])) {422 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 423 (image->data.F32[row][col] > image->data.F32[row][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-1]) && 426 (image->data.F32[row][col] >= image->data.F32[row+1][col])) { 428 427 myType = PM_PEAK_EDGE; 429 428 list = myListAddPeak(list, row, col, image->data.F32[row][col], myType); … … 448 447 if (col == 0) { 449 448 if ( (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 (image->data.F32[row][col] > image->data.F32[row][col+1])) {449 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) && 450 (image->data.F32[row][col] > image->data.F32[row][col+1])) { 452 451 if (image->data.F32[row][col] > threshold) { 453 452 list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE); … … 456 455 } else if (col < (image->numCols - 1)) { 457 456 if ( (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 458 (image->data.F32[row][col] > image->data.F32[row-1][col]) &&459 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&460 (image->data.F32[row][col] > image->data.F32[row][col-1]) &&461 (image->data.F32[row][col] >= image->data.F32[row][col+1])) {457 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 458 (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) && 459 (image->data.F32[row][col] > image->data.F32[row][col-1]) && 460 (image->data.F32[row][col] >= image->data.F32[row][col+1])) { 462 461 if (image->data.F32[row][col] > threshold) { 463 462 list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE); … … 467 466 } else if (col == (image->numCols - 1)) { 468 467 if ( (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) && 469 (image->data.F32[row][col] > image->data.F32[row-1][col]) &&470 (image->data.F32[row][col] > image->data.F32[row][col-1])) {468 (image->data.F32[row][col] > image->data.F32[row-1][col]) && 469 (image->data.F32[row][col] > image->data.F32[row][col-1])) { 471 470 if (image->data.F32[row][col] > threshold) { 472 471 list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE); … … 495 494 (y >= valid->y0) && 496 495 (y <= valid->y1)) { 497 return(true);496 return(true); 498 497 } 499 498 … … 511 510 512 511 XXX: changed API to create a NEW output psArray (should change name as well) 512 513 XXX: Do we free the psList elements of those culled peaks? 514 515 XXX EAM : do we still need pmCullPeaks, or only pmPeaksSubset? 513 516 *****************************************************************************/ 514 517 psList *pmCullPeaks(psList *peaks, … … 517 520 { 518 521 PS_ASSERT_PTR_NON_NULL(peaks, NULL); 519 // PS_ASSERT_PTR_NON_NULL(valid, NULL);520 522 521 523 psListElem *tmpListElem = (psListElem *) peaks->head; … … 526 528 pmPeak *tmpPeak = (pmPeak *) tmpListElem->data; 527 529 if ((tmpPeak->counts > maxValue) || 528 ((valid != NULL) &&529 (true == isItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {530 ((valid != NULL) && 531 (true == isItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) { 530 532 psListRemoveData(peaks, (psPtr) tmpPeak); 531 533 } … … 625 627 // XXX EAM : I added this code to stay on the image. So did George 626 628 // XXX EAM : EndRow is *exclusive* of pixel region (ie, last pixel + 1) 629 // XXX EAM : dropped the Annulus width (not needed) 630 // XXX EAM : dropped off-boundary tests (not needed) 627 631 psS32 SubImageStartRow = PS_MAX (0, SubImageCenterRow - outerRadiusS32); 628 632 psS32 SubImageEndRow = PS_MIN (image->numRows, SubImageCenterRow + outerRadiusS32 + 1); 629 633 psS32 SubImageStartCol = PS_MAX (0, SubImageCenterCol - outerRadiusS32); 630 634 psS32 SubImageEndCol = PS_MIN (image->numCols, SubImageCenterCol + outerRadiusS32 + 1); 631 // AnulusWidth == number of pixels width in the annulus. We add one since632 // the pixels at the inner AND outher radius are included.633 // XXX EAM : not used : psS32 AnulusWidth = 1 + (outerRadiusS32 - innerRadiusS32);634 // Example: assume an outer/inner radius of 20/10. Then the subimage635 // should have width/length of 40. An 18-by-18 interior region will636 // be masked.637 // printf("pmSourceLocalSky(): innerRadiusS32 is %d\n", innerRadiusS32);638 // printf("pmSourceLocalSky(): outerRadiusS32 is %d\n", outerRadiusS32);639 // printf("pmSourceLocalSky(): AnulusWidth is %d\n", AnulusWidth);640 641 // XXX EAM : these tests should not be needed: we can never hit this error because of above642 # if (1)643 644 if (SubImageStartRow < 0) {645 psError(PS_ERR_UNKNOWN, true, "Sub image startRow is outside image boundaries (%d).\n",646 SubImageStartRow);647 return(NULL);648 }649 if (SubImageEndRow > image->numRows) {650 psError(PS_ERR_UNKNOWN, true, "Sub image endRow is outside image boundaries (%d).\n",651 SubImageEndRow);652 return(NULL);653 }654 if (SubImageStartCol < 0) {655 psError(PS_ERR_UNKNOWN, true, "Sub image startCol is outside image boundaries (%d).\n",656 SubImageStartCol);657 return(NULL);658 }659 if (SubImageEndCol > image->numCols) {660 psError(PS_ERR_UNKNOWN, true, "Sub image endCol is outside image boundaries (%d).\n",661 SubImageEndCol);662 return(NULL);663 }664 # endif665 666 635 // 667 636 // Grab a subimage of the original image of size (2 * outerRadius). 668 637 // 669 // XXX: Must fix for new psImageSubset 670 // psImage *subImage = psImageSubset((psImage *) image, 671 // SubImageStartCol, 672 // SubImageStartRow, 673 // SubImageEndCol, 674 // SubImageEndRow); 675 // printf("pmSourceLocalSky: subimage width/length is (%d, %d)\n", subImage->numCols, subImage->numRows); 676 psRegion tmpRegion = psRegionSet(SubImageStartCol, 677 SubImageEndCol, 678 SubImageStartRow, 679 SubImageEndRow); 680 psImage *subImage = psImageSubset((psImage *) image, tmpRegion); 681 // XXX EAM : can merge these: psImageSubset (image, psRegionSet ()); 638 // XXX EAM : merged psImageSubset & psRegionSet 639 // XXX EAM : cast for image is needed because of const (above) 640 psImage *subImage = psImageSubset((psImage *) image, psRegionSet(SubImageStartCol, 641 SubImageEndCol, 642 SubImageStartRow, 643 SubImageEndRow)); 682 644 683 645 psImage *subImageMask = psImageAlloc(subImage->numCols, … … 685 647 PS_TYPE_U8); 686 648 // XXX EAM : for consistency, mask needs col0,row0 set to match image 687 subImageMask->col0 = subImage->col0; 688 subImageMask->row0 = subImage->row0; 689 690 // 691 // Loop through the subimage mask, initialize mask to 1 (invalid pixel) 649 // XXX EAM : CONFLICT between psLib and code requirement. FIX PSLIB!!! 650 // subImageMask->col0 = subImage->col0; 651 // subImageMask->row0 = subImage->row0; 652 psAbort ("pmObjects", "must fix this error before psphot will work!!!\n"); 653 654 // 655 // Loop through the subimage mask, initialize mask to 0x01 (invalid pixel) 692 656 // XXX EAM : use PSPHOT_MASK_INVALID? 693 657 // 694 658 for (psS32 row = 0 ; row < subImageMask->numRows; row++) { 695 659 for (psS32 col = 0 ; col < subImageMask->numCols; col++) { 696 subImageMask->data.U8[row][col] = 1;660 subImageMask->data.U8[row][col] = 0x01; 697 661 } 698 662 } … … 702 666 // XXX this uses a static mask value of 0 703 667 // XXX EAM : this was wrong: it masked the wrong pixels at the edge of the image 668 // XXX EAM : this masks the pixels in the center region 669 // XXX EAM : should we be using psImageMaskRegion ??? 704 670 psS32 StartRow = PS_MAX (0, SubImageCenterRow - subImageMask->row0 - innerRadiusS32); 705 671 psS32 EndRow = PS_MIN (subImageMask->numRows, SubImageCenterRow - subImageMask->row0 + innerRadiusS32 + 1); … … 712 678 } 713 679 714 680 // XXX EAM : make this trace information?? 715 681 // for (psS32 row = 0 ; row < subImage->numRows; row++) { 716 682 // for (psS32 col = 0 ; col < subImage->numCols; col++) { … … 800 766 XXX: mask values? 801 767 *****************************************************************************/ 802 bool pmSourceMoments(p sSource *source,768 bool pmSourceMoments(pmSource *source, 803 769 psF32 radius) 804 770 { … … 849 815 psS32 imgColCoord = col + source->pixels->col0; 850 816 psS32 imgRowCoord = row + source->pixels->row0; 851 if ( CheckRadius(source->peak,817 if (checkRadius(source->peak, 852 818 radius, 853 819 imgColCoord, … … 874 840 // XXX EAM - the limit is a bit arbitrary. make it user defined? 875 841 if ((numPixels < 3) || (Sum <= 0)) { 876 psTrace (".psModules.pmSourceMoments", 5, "no valid pixels for source\n");877 return (false);842 psTrace (".psModules.pmSourceMoments", 5, "no valid pixels for source\n"); 843 return (false); 878 844 } 879 845 … … 890 856 y = Y1/Sum; 891 857 if ((fabs(x) > radius) || (fabs(y) > radius)) { 892 psTrace (".psModules.pmSourceMoments", 5,893 "large centroid swing; invalid peak %d, %d\n",894 source->peak->x, source->peak->y);895 return (false);858 psTrace (".psModules.pmSourceMoments", 5, 859 "large centroid swing; invalid peak %d, %d\n", 860 source->peak->x, source->peak->y); 861 return (false); 896 862 } 897 863 … … 914 880 915 881 return(true); 916 917 // XXX EAM : the following code should be the same as above, but it is not very stable: ignore it918 # if (0)919 //920 // second loop: get the difference sums921 //922 X2 = Y2 = 0;923 for (psS32 row = 0; row < source->pixels->numRows ; row++) {924 for (psS32 col = 0; col < source->pixels->numCols ; col++) {925 if ((source->mask != NULL) && (source->mask->data.U8[row][col] != 0)) {926 psS32 imgColCoord = col + source->pixels->col0;927 psS32 imgRowCoord = row + source->pixels->row0;928 if (checkRadius(source->peak,929 radius,930 imgColCoord,931 imgRowCoord)) {932 psF32 xDiff = (psF32) (imgColCoord - source->peak->x);933 psF32 yDiff = (psF32) (imgRowCoord - source->peak->y);934 psF32 pDiff = source->pixels->data.F32[row][col] - sky;935 936 Sum+= pDiff;937 X2+= PS_SQR(xDiff - x) * pDiff;938 Y2+= PS_SQR(yDiff - y) * pDiff;939 }940 }941 }942 }943 944 //945 // second moment X = sqrt (X2/Sum)946 //947 source->moments->Sx = (X2/Sum);948 source->moments->Sy = (Y2/Sum);949 return(true);950 # endif951 882 } 952 883 … … 990 921 { 991 922 992 # define NPIX 10993 # define SCALE 0.1923 # define NPIX 10 924 # define SCALE 0.1 994 925 995 926 psArray *peaks = NULL; … … 997 928 pmPSFClump psfClump = emptyClump; 998 929 999 // PS_PTR_CHECK_NULL(sources, emptyClump);1000 // PS_PTR_CHECK_NULL(metadata, emptyClump);930 PS_ASSERT_PTR_NON_NULL(sources, emptyClump); 931 PS_ASSERT_PTR_NON_NULL(metadata, emptyClump); 1001 932 1002 933 // find the sigmaX, sigmaY clump … … 1010 941 splane = psImageAlloc (NPIX/SCALE, NPIX/SCALE, PS_TYPE_F32); 1011 942 for (int i = 0; i < splane->numRows; i++) { 1012 memset (splane->data.F32[i], 0, splane->numCols*sizeof(PS_TYPE_F32));943 memset (splane->data.F32[i], 0, splane->numCols*sizeof(PS_TYPE_F32)); 1013 944 } 1014 945 … … 1139 1070 1140 1071 XXX: How can this function ever return FALSE? 1072 1073 XXX EAM : add the saturated mask value to metadata 1141 1074 *****************************************************************************/ 1142 1075 … … 1178 1111 psF32 A = 4 * M_PI * sigX * sigY; 1179 1112 psF32 B = tmpSrc->moments->Sky; 1180 psF32 RT = PS_SQRT_F32(S + (A * B) + (A * PS_SQR(RDNOISE) / PS_SQRT_F32(GAIN)));1181 psF32 SN = (S * PS_SQRT_F32(GAIN) / RT);1113 psF32 RT = sqrt(S + (A * B) + (A * PS_SQR(RDNOISE) / sqrt(GAIN))); 1114 psF32 SN = (S * sqrt(GAIN) / RT); 1182 1115 tmpSrc->moments->SN = SN; 1183 1116 1184 // XXX EAM : can we use the value of SATIRATE if mask is NULL? 1185 int Nsatpix = pmCountSatPixels (tmpSrc->mask); 1117 // XXX EAM : can we use the value of SATURATE if mask is NULL? 1118 # define MASK_SATURATED 0x02 1119 int Nsatpix = psImageCountPixelMask (tmpSrc->mask, MASK_SATURATED); 1186 1120 1187 1121 // saturated star (size consistent with PSF or larger) … … 1253 1187 } 1254 1188 1255 int pmCountSatPixels (psImage *image)1256 {1257 int Nsatpix = 0;1258 1259 for (int i = 0; i < image->numRows; i++) {1260 for (int j = 0; j < image->numCols; j++) {1261 if (image->data.U8[i][j] & 0x02) {1262 Nsatpix ++;1263 }1264 }1265 }1266 return (Nsatpix);1267 }1268 1269 1189 /****************************************************************************** 1270 1190 pmSourceSetPixelsCircle(source, image, radius) … … 1286 1206 PS_ASSERT_PTR_NON_NULL(source, false); 1287 1207 PS_ASSERT_PTR_NON_NULL(source->moments, false); 1288 //PS_ASSERT_PTR_NON_NULL(source->peak, false);1208 PS_ASSERT_PTR_NON_NULL(source->peak, false); 1289 1209 PS_FLOAT_COMPARE(0.0, radius, false); 1290 1210 … … 1305 1225 psS32 SubImageEndCol = PS_MIN (image->numCols, SubImageCenterCol + radiusS32 + 1); 1306 1226 1307 // XXX EAM : this should not be needed: we can never hit this error1308 # if (1)1309 1310 if (SubImageStartRow < 0) {1311 psError(PS_ERR_UNKNOWN, true, "Sub image startRow is outside image boundaries (%d).\n",1312 SubImageStartRow);1313 return(false);1314 }1315 if (SubImageEndRow > image->numRows) {1316 psError(PS_ERR_UNKNOWN, true, "Sub image endRow is outside image boundaries (%d).\n",1317 SubImageEndRow);1318 return(false);1319 }1320 if (SubImageStartCol < 0) {1321 psError(PS_ERR_UNKNOWN, true, "Sub image startCol is outside image boundaries (%d).\n",1322 SubImageStartCol);1323 return(false);1324 }1325 if (SubImageEndCol > image->numCols) {1326 psError(PS_ERR_UNKNOWN, true, "Sub image endCol is outside image boundaries (%d).\n",1327 SubImageEndCol);1328 return(false);1329 }1330 # endif1331 1332 1227 // XXX: Must recycle image. 1333 1228 // XXX EAM: this message reflects a programming error we know about. … … 1338 1233 psFree(source->pixels); 1339 1234 } 1340 // XXX: Must fix this. psImageSubset() has different parameters in latest CVS.1341 // source->pixels = psImageSubset((psImage *) image,1342 // SubImageStartCol,1343 // SubImageStartRow,1344 // SubImageEndCol,1345 // SubImageEndRow);1346 1235 source->pixels = psImageSubset((psImage *) image, psRegionSet(SubImageStartCol, 1347 1236 SubImageStartRow, … … 1390 1279 functions will be in image, not subImage coords. Remember this. 1391 1280 *****************************************************************************/ 1392 psModel *pmSourceModelGuess(psSource *source, 1393 psModelType modelType) 1394 { 1395 PS_PTR_CHECK_NULL(source, false); 1396 PS_PTR_CHECK_NULL(source->moments, false); 1397 PS_PTR_CHECK_NULL(source->peak, false); 1398 1399 psModel *model = psModelAlloc(modelType); 1400 1401 psModelGuessFunc modelGuessFunc = psModelGuessFunc_GetFunction (modelType); 1281 pmModel *pmSourceModelGuess(pmSource *source, 1282 pmModelType modelType) 1283 { 1284 PS_ASSERT_PTR_NON_NULL(source->moments, false); 1285 PS_ASSERT_PTR_NON_NULL(source->peak, false); 1286 1287 pmModel *model = pmModelAlloc(modelType); 1288 1289 pmModelGuessFunc modelGuessFunc = pmModelGuessFunc_GetFunction (modelType); 1402 1290 modelGuessFunc (model, source); 1403 1291 return(model); … … 1425 1313 testing. Try to reproduce that and debug. 1426 1314 *****************************************************************************/ 1427 static psF32 evalModel(pmSource *src, 1428 psU32 row, 1429 psU32 col) 1430 { 1431 PS_ASSERT_PTR_NON_NULL(src, false); 1432 PS_ASSERT_PTR_NON_NULL(src->modelPSF, false); 1433 PS_ASSERT_PTR_NON_NULL(src->modelPSF->params, false); 1434 1435 XXX EAM : I've made this a public function 1436 XXX EAM : this now uses a psModel as the input 1437 XXX EAM : it was using src->type to find the model, not model->type 1438 *****************************************************************************/ 1439 psF32 psModelEval(psModel *model, psImage *image, psS32 col, psS32 row) 1440 { 1441 PS_PTR_CHECK_NULL(image, false); 1442 PS_PTR_CHECK_NULL(model, false); 1443 PS_PTR_CHECK_NULL(model->params, false); 1315 1316 // XXX EAM : I have made this a public function 1317 // XXX EAM : this now uses a pmModel as the input 1318 // XXX EAM : it was using src->type to find the model, not model->type 1319 psF32 pmModelEval(pmModel *model, psImage *image, psS32 col, psS32 row) 1320 { 1321 PS_ASSERT_PTR_NON_NULL(image, false); 1322 PS_ASSERT_PTR_NON_NULL(model, false); 1323 PS_ASSERT_PTR_NON_NULL(model->params, false); 1444 1324 1445 1325 // Allocate the x coordinate structure and convert row/col to image space. … … 1449 1329 x->data.F32[1] = (psF32) (row + image->row0); 1450 1330 psF32 tmpF; 1451 p sModelFunc modelFunc;1452 1453 modelFunc = p sModelFunc_GetFunction (model->type);1331 pmModelFunc modelFunc; 1332 1333 modelFunc = pmModelFunc_GetFunction (model->type); 1454 1334 tmpF = modelFunc (NULL, model->params, x); 1455 1335 psFree(x); … … 1491 1371 } 1492 1372 1493 // XXX EAM : i changed this to match p sModelEval above, but see1373 // XXX EAM : i changed this to match pmModelEval above, but see 1494 1374 // XXX EAM the note below in pmSourceContour 1495 psF32 oldValue = p sModelEval(source->modelFLT, source->pixels, subCol, subRow);1375 psF32 oldValue = pmModelEval(source->modelFLT, source->pixels, subCol, subRow); 1496 1376 if (oldValue == level) { 1497 1377 return(((psF32) (subCol + source->pixels->col0))); … … 1514 1394 1515 1395 while (subCol != lastColumn) { 1516 psF32 newValue = p sModelEval(source->modelFLT, source->pixels, subCol, subRow);1396 psF32 newValue = pmModelEval(source->modelFLT, source->pixels, subCol, subRow); 1517 1397 if (oldValue == level) { 1518 1398 return((psF32) (subCol + source->pixels->col0)); … … 1674 1554 // tests below could be conditions (!NULL) 1675 1555 1676 p sModelFunc modelFunc = psModelFunc_GetFunction (model->type);1556 pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type); 1677 1557 1678 1558 psVector *params = model->params; … … 1694 1574 } 1695 1575 if (count < nParams + 1) { 1696 psTrace (".pmObjects.pmSourceFitModel", 4, "insufficient valid pixels\n");1697 return(false);1576 psTrace (".pmObjects.pmSourceFitModel", 4, "insufficient valid pixels\n"); 1577 return(false); 1698 1578 } 1699 1579 … … 1722 1602 1723 1603 psMinimization *myMin = psMinimizationAlloc(PM_SOURCE_FIT_MODEL_NUM_ITERATIONS, 1724 PM_SOURCE_FIT_MODEL_TOLERANCE);1604 PM_SOURCE_FIT_MODEL_TOLERANCE); 1725 1605 1726 1606 // PSF model only fits first 4 parameters, FLT model fits all 1727 1607 if (PSF) { 1728 paramMask = psVectorAlloc (params->n, PS_TYPE_U8);1729 for (int i = 0; i < 4; i++) {1730 paramMask->data.U8[i] = 0;1731 }1732 for (int i = 4; i < paramMask->n; i++) {1733 paramMask->data.U8[i] = 1;1734 }1608 paramMask = psVectorAlloc (params->n, PS_TYPE_U8); 1609 for (int i = 0; i < 4; i++) { 1610 paramMask->data.U8[i] = 0; 1611 } 1612 for (int i = 4; i < paramMask->n; i++) { 1613 paramMask->data.U8[i] = 1; 1614 } 1735 1615 } 1736 1616 … … 1782 1662 bool p_pmSourceAddOrSubModel(psImage *image, 1783 1663 psImage *mask, 1784 p sModel *model,1664 pmModel *model, 1785 1665 bool center, 1786 1666 psS32 flag) 1787 1667 { 1788 1668 1789 // XXX EAM : convert to ASSERTS 1790 // PS_PTR_CHECK_NULL(model, false); 1791 // PS_IMAGE_CHECK_NULL(image, false); 1792 // PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, false); 1669 PS_ASSERT_PTR_NON_NULL(model, false); 1670 PS_ASSERT_IMAGE_NON_NULL(image, false); 1671 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, false); 1793 1672 1794 1673 psVector *x = psVectorAlloc(2, PS_TYPE_F32); 1795 1674 psVector *params = model->params; 1796 p sModelFunc modelFunc = psModelFunc_GetFunction (model->type);1675 pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type); 1797 1676 psS32 imageCol; 1798 1677 psS32 imageRow; … … 1842 1721 bool pmSourceAddModel(psImage *image, 1843 1722 psImage *mask, 1844 p sModel *model,1723 pmModel *model, 1845 1724 bool center) 1846 1725 { … … 1852 1731 bool pmSourceSubModel(psImage *image, 1853 1732 psImage *mask, 1854 p sModel *model,1733 pmModel *model, 1855 1734 bool center) 1856 1735 {
Note:
See TracChangeset
for help on using the changeset viewer.
