Changeset 3699 for trunk/psModules/src/pmObjects.c
- Timestamp:
- Apr 13, 2005, 4:42:41 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmObjects.c (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmObjects.c
r3698 r3699 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-04-14 02: 07:10$7 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-04-14 02:42:41 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 313 313 of all peaks. 314 314 315 XXX: I'm not convinced the peak type definition in the SDRS is mutually 316 exclusive. Some peaks can have multiple types. Edges for sure. Also, a 317 digonal line with the same value at each point will have a peak for every 318 point on that line. 315 XXX: For multiple type peaks, ensure that each is set. 319 316 320 317 XXX: This does not work if image has either a single row, or a single column. 321 322 XXX: In the output psList elements, should we use the image row/column offsets? 323 Currently, we do not. 324 *****************************************************************************/ 318 *****************************************************************************/ 325 319 psList *pmFindImagePeaks(const psImage *image, 326 320 psF32 threshold) … … 391 385 // 392 386 for (row = 1 ; row < (image->numRows - 1) ; row++) { 393 tmpRow = p_psGetRowVectorFromImage((psImage *) image, 0);387 tmpRow = p_psGetRowVectorFromImage((psImage *) image, row); 394 388 row1 = pmFindVectorPeaks(tmpRow, threshold); 395 389 … … 507 501 508 502 503 /****************************************************************************** 504 PS_REGION_CHECK(VALID, X, Y): this macro evaluates to TRUE if the coordinate 505 (X, Y) is within REGION, otherwise it evaluates to FALSE. 506 *****************************************************************************/ 509 507 #define PS_REGION_CHECK(VALID, X, Y) \ 510 508 (((X) >= (VALID)->x0) && \ … … 513 511 ((Y) <= (VALID)->y1)) 514 512 515 // XXX: Macro this.516 bool IsItInThisRegion(const psRegion *valid,517 psS32 x,518 psS32 y)519 {520 521 if ((x >= valid->x0) &&522 (x <= valid->x1) &&523 (y >= valid->y0) &&524 (y <= valid->y1)) {525 return(true);526 }527 528 return(false);529 }530 531 513 532 514 /****************************************************************************** 533 515 psCullPeaks(peaks, maxValue, valid): eliminate peaks from the psList that have 534 516 a peak value above the given maximum, or fall outside the valid region. 535 536 XXX: Should the sky value be used when comparing the maximum? 537 538 XXX: warning message if valid is NULL? 539 *****************************************************************************/ 517 *****************************************************************************/ 540 518 psList *pmCullPeaks(psList *peaks, 541 519 psF32 maxValue, … … 543 521 { 544 522 PS_PTR_CHECK_NULL(peaks, NULL); 545 // PS_PTR_CHECK_NULL(valid, NULL); 523 if (valid == NULL) { 524 psLogMsg(__func__, PS_LOG_WARN, "WARNING: psRegion valid is NULL. Ignoring ...\n"); 525 } 546 526 547 527 psListElem *tmpListElem = (psListElem *) peaks->head; 548 528 psS32 indexNum = 0; 549 529 550 // printf("pmCullPeaks(): list size is %d\n", peaks->size);551 530 while (tmpListElem != NULL) { 552 531 psPeak *tmpPeak = (psPeak *) tmpListElem->data; 553 532 if ((tmpPeak->counts > maxValue) || 554 533 ((valid != NULL) && 555 // (true == IsItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {556 534 (true == PS_REGION_CHECK(valid, tmpPeak->x, tmpPeak->y)))) { 557 535 psListRemoveData(peaks, (psPtr) tmpPeak); … … 576 554 We simply create a subSet image and mask the inner pixels, then call 577 555 psImageStats on that subImage+mask. 578 579 XXX: The subImage has width of 1+2*outerRadius. Verify with IfA.580 556 581 557 XXX: Use static data structures for: … … 726 702 727 703 /****************************************************************************** 728 bool CheckRadius(*peak, radius, x, y): private function which simply 729 determines if the (x, y) point is within the radius of the specified peak. 730 731 XXX: macro this for performance. 704 bool PS_RADIUS_CHECK(): a macro which evaluates to TRUE if the (x, y) point is 705 within the radius of the specified peak. 732 706 *****************************************************************************/ 733 bool CheckRadius(psPeak *peak, 734 psF32 radius, 735 psS32 x, 736 psS32 y) 737 { 738 if (PS_SQR(radius) >= (psF32) (PS_SQR(x - peak->x) + PS_SQR(y - peak->y))) { 739 return(true); 740 } 741 742 return(false); 743 } 744 745 /****************************************************************************** 746 bool CheckRadius2(): private function which simply determines if the (x, y) 747 point is within the radius of the specified peak. 748 749 XXX: macro this for performance. 707 #define PS_RADIUS_CHECK(PEAK, RADIUS, X, Y) \ 708 (PS_SQR((RADIUS)) >= ((psF32) (PS_SQR((X) - (PEAK)->x) + PS_SQR((Y) - (PEAK)->y)))) 709 710 711 /****************************************************************************** 712 bool PS_RADIUS_CHECK22(): a macro which evaluates to TRUE if the (x, y) point 713 is within the radius of the specified point. 750 714 *****************************************************************************/ 751 bool CheckRadius2(psF32 xCenter, 752 psF32 yCenter, 753 psF32 radius, 754 psF32 x, 755 psF32 y) 756 { 757 if ((PS_SQR(x - xCenter) + PS_SQR(y - yCenter)) < PS_SQR(radius)) { 758 return(true); 759 } 760 761 return(false); 762 } 715 #define PS_RADIUS_CHECK2(X_CENTER, Y_CENTER, RADIUS, X, Y) \ 716 (PS_SQR((RADIUS)) >= ((psF32) (PS_SQR((X) - (X_CENTER)) + PS_SQR((Y) - (Y_CENTER))))) 717 718 763 719 764 720 /****************************************************************************** … … 772 728 psSource->pixels 773 729 774 XXX: The peak calculations are done in image coords, not subImage coords.775 776 730 XXX: mask values? 777 731 *****************************************************************************/ … … 784 738 PS_FLOAT_COMPARE(0.0, radius, NULL); 785 739 786 //787 // XXX: Verify the setting for sky if source->moments == NULL.788 //789 740 psF32 sky = 0.0; 790 741 if (source->moments == NULL) { 791 source->moments = pmMomentsAlloc(); 742 psError(PS_ERR_UNKNOWN, true, "Undefined source->psMoments is NULL"); 743 psFree(source); 744 return(NULL); 792 745 } else { 793 746 sky = source->moments->Sky; … … 818 771 psS32 imgColCoord = col + source->pixels->col0; 819 772 psS32 imgRowCoord = row + source->pixels->row0; 820 if ( CheckRadius(source->peak,821 radius,822 imgColCoord,823 imgRowCoord)) {773 if (PS_RADIUS_CHECK(source->peak, 774 radius, 775 imgColCoord, 776 imgRowCoord)) { 824 777 psF32 xDiff = (psF32) (imgColCoord - source->peak->x); 825 778 psF32 yDiff = (psF32) (imgRowCoord - source->peak->y); … … 866 819 867 820 XXX: The sigX and sigY stuff in the SDRS is unclear. 868 869 XXX: How can this function ever return FALSE?870 821 *****************************************************************************/ 871 822 #define SATURATE 0.0 … … 941 892 pmSourceSetPixelCircle(source, image, radius) 942 893 943 XXX: Why boolean output? 944 945 XXX: Why are we checking source->moments for NULL? Should the circle be 946 centered on the centroid or the peak? 947 948 XXX: The circle will have a diameter of (1+radius). This is different from 949 the pmSourceSetLocal() function. 894 XXX: Checking source->moments for NULL. Circle must be centered on the 895 centroid, not peak (from IfA 2005-04-06). 950 896 *****************************************************************************/ 951 897 bool pmSourceSetPixelCircle(psSource *source, … … 1021 967 for (psS32 col = 0 ; col < source->mask->numCols; col++) { 1022 968 1023 if ( CheckRadius2((psF32) radiusS32,1024 (psF32) radiusS32,1025 radius,1026 (psF32) col,1027 (psF32) row)) {969 if (PS_RADIUS_CHECK2((psF32) radiusS32, 970 (psF32) radiusS32, 971 radius, 972 (psF32) col, 973 (psF32) row)) { 1028 974 source->mask->data.U8[row][col] = 1; 1029 975 } else { … … 1151 1097 1152 1098 /****************************************************************************** 1153 evalModel(s ource, level, row): a private function which evaluates the1099 evalModel(src, col, row): a private function which evaluates the 1154 1100 source->model function at the specified coords. The coords are subImage, not 1155 1101 image coords. … … 1157 1103 NOTE: The coords are in subImage source->pixel coords, not image coords. 1158 1104 1159 XXX: reverse order of row,col args?1160 1161 1105 XXX: rename all coords in this file such that their name defines whether 1162 1106 the coords is in subImage or image space. … … 1172 1116 *****************************************************************************/ 1173 1117 psF32 evalModel(psSource *src, 1174 psU32 row,1175 psU32 col)1118 psU32 col, 1119 psU32 row) 1176 1120 { 1177 1121 PS_PTR_CHECK_NULL(src, false); … … 1224 1168 1225 1169 /****************************************************************************** 1226 findValue(source, level, row, col, dir): a private function which determines1170 findValue(source, level, col, row, dir): a private function which determines 1227 1171 the column coordinate of the model function which has the value "level". If 1228 1172 dir equals 0, then you loop leftwards from the peak pixel, otherwise, 1229 1173 rightwards. 1230 1174 1231 XXX: reverse order of row,col args?1232 1233 1175 XXX: Input row/col are in image coords. 1234 1176 … … 1237 1179 psF32 findValue(psSource *source, 1238 1180 psF32 level, 1181 psU32 col, 1239 1182 psU32 row, 1240 psU32 col,1241 1183 psU32 dir) 1242 1184 { … … 1257 1199 } 1258 1200 1259 psF32 oldValue = evalModel(source, sub Row, subCol);1201 psF32 oldValue = evalModel(source, subCol, subRow); 1260 1202 if (oldValue == level) { 1261 1203 return(((psF32) (subCol + source->pixels->col0))); … … 1278 1220 1279 1221 while (subCol != lastColumn) { 1280 psF32 newValue = evalModel(source, sub Row, subCol);1222 psF32 newValue = evalModel(source, subCol, subRow); 1281 1223 if (oldValue == level) { 1282 1224 return((psF32) (subCol + source->pixels->col0)); … … 1338 1280 1339 1281 // Starting at peak pixel, search leftwards for the column intercept. 1340 psF32 leftIntercept = findValue(source, level, row, col, 0);1282 psF32 leftIntercept = findValue(source, level, col, row, 0); 1341 1283 if (isnan(leftIntercept)) { 1342 1284 psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)"); … … 1349 1291 // Starting at peak pixel, search rightwards for the column intercept. 1350 1292 1351 psF32 rightIntercept = findValue(source, level, row, col, 1);1293 psF32 rightIntercept = findValue(source, level, col, row, 1); 1352 1294 if (isnan(rightIntercept)) { 1353 1295 psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)"); … … 1372 1314 1373 1315 // Starting at peak pixel, search leftwards for the column intercept. 1374 psF32 leftIntercept = findValue(source, level, row, col, 0);1316 psF32 leftIntercept = findValue(source, level, col, row, 0); 1375 1317 if (isnan(leftIntercept)) { 1376 1318 psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)"); … … 1382 1324 1383 1325 // Starting at peak pixel, search rightwards for the column intercept. 1384 psF32 rightIntercept = findValue(source, level, row, col, 1);1326 psF32 rightIntercept = findValue(source, level, col, row, 1); 1385 1327 if (isnan(rightIntercept)) { 1386 1328 psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
Note:
See TracChangeset
for help on using the changeset viewer.
