IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 13, 2005, 4:42:41 PM (21 years ago)
Author:
gusciora
Message:

Fixed type (bug 359).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/pmObjects.c

    r3698 r3699  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.15 $ $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 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    313313of all peaks.
    314314 
    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.
     315XXX: For multiple type peaks, ensure that each is set.
    319316 
    320317XXX: 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  *****************************************************************************/
    325319psList *pmFindImagePeaks(const psImage *image,
    326320                         psF32 threshold)
     
    391385    //
    392386    for (row = 1 ; row < (image->numRows - 1) ; row++) {
    393         tmpRow = p_psGetRowVectorFromImage((psImage *) image, 0);
     387        tmpRow = p_psGetRowVectorFromImage((psImage *) image, row);
    394388        row1 = pmFindVectorPeaks(tmpRow, threshold);
    395389
     
    507501
    508502
     503/******************************************************************************
     504PS_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 *****************************************************************************/
    509507#define PS_REGION_CHECK(VALID, X, Y) \
    510508(((X) >= (VALID)->x0) && \
     
    513511 ((Y) <= (VALID)->y1))
    514512
    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 
    531513
    532514/******************************************************************************
    533515psCullPeaks(peaks, maxValue, valid): eliminate peaks from the psList that have
    534516a 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  *****************************************************************************/
    540518psList *pmCullPeaks(psList *peaks,
    541519                    psF32 maxValue,
     
    543521{
    544522    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    }
    546526
    547527    psListElem *tmpListElem = (psListElem *) peaks->head;
    548528    psS32 indexNum = 0;
    549529
    550     //    printf("pmCullPeaks(): list size is %d\n", peaks->size);
    551530    while (tmpListElem != NULL) {
    552531        psPeak *tmpPeak = (psPeak *) tmpListElem->data;
    553532        if ((tmpPeak->counts > maxValue) ||
    554533                ((valid != NULL) &&
    555                  //                 (true == IsItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {
    556534                 (true == PS_REGION_CHECK(valid, tmpPeak->x, tmpPeak->y)))) {
    557535            psListRemoveData(peaks, (psPtr) tmpPeak);
     
    576554We simply create a subSet image and mask the inner pixels, then call
    577555psImageStats on that subImage+mask.
    578  
    579 XXX: The subImage has width of 1+2*outerRadius.  Verify with IfA.
    580556 
    581557XXX: Use static data structures for:
     
    726702
    727703/******************************************************************************
    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.
     704bool PS_RADIUS_CHECK(): a macro which evaluates to TRUE if the (x, y) point is
     705within the radius of the specified peak.
    732706  *****************************************************************************/
    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/******************************************************************************
     712bool PS_RADIUS_CHECK22(): a macro which evaluates to TRUE if the (x, y) point
     713is within the radius of the specified point.
    750714  *****************************************************************************/
    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
    763719
    764720/******************************************************************************
     
    772728    psSource->pixels
    773729 
    774 XXX: The peak calculations are done in image coords, not subImage coords.
    775  
    776730XXX: mask values?
    777731 *****************************************************************************/
     
    784738    PS_FLOAT_COMPARE(0.0, radius, NULL);
    785739
    786     //
    787     // XXX: Verify the setting for sky if source->moments == NULL.
    788     //
    789740    psF32 sky = 0.0;
    790741    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);
    792745    } else {
    793746        sky = source->moments->Sky;
     
    818771                psS32 imgColCoord = col + source->pixels->col0;
    819772                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)) {
    824777                    psF32 xDiff = (psF32) (imgColCoord - source->peak->x);
    825778                    psF32 yDiff = (psF32) (imgRowCoord - source->peak->y);
     
    866819 
    867820XXX: The sigX and sigY stuff in the SDRS is unclear.
    868  
    869 XXX: How can this function ever return FALSE?
    870821 *****************************************************************************/
    871822#define SATURATE 0.0
     
    941892pmSourceSetPixelCircle(source, image, radius)
    942893 
    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.
     894XXX: Checking source->moments for NULL.  Circle must be centered on the
     895     centroid, not peak (from IfA 2005-04-06).
    950896 *****************************************************************************/
    951897bool pmSourceSetPixelCircle(psSource *source,
     
    1021967        for (psS32 col = 0 ; col < source->mask->numCols; col++) {
    1022968
    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)) {
    1028974                source->mask->data.U8[row][col] = 1;
    1029975            } else {
     
    11511097
    11521098/******************************************************************************
    1153 evalModel(source, level, row): a private function which evaluates the
     1099evalModel(src, col, row): a private function which evaluates the
    11541100source->model function at the specified coords.  The coords are subImage, not
    11551101image coords.
     
    11571103NOTE: The coords are in subImage source->pixel coords, not image coords.
    11581104 
    1159 XXX: reverse order of row,col args?
    1160  
    11611105XXX: rename all coords in this file such that their name defines whether
    11621106the coords is in subImage or image space.
     
    11721116 *****************************************************************************/
    11731117psF32 evalModel(psSource *src,
    1174                 psU32 row,
    1175                 psU32 col)
     1118                psU32 col,
     1119                psU32 row)
    11761120{
    11771121    PS_PTR_CHECK_NULL(src, false);
     
    12241168
    12251169/******************************************************************************
    1226 findValue(source, level, row, col, dir): a private function which determines
     1170findValue(source, level, col, row, dir): a private function which determines
    12271171the column coordinate of the model function which has the value "level".  If
    12281172dir equals 0, then you loop leftwards from the peak pixel, otherwise,
    12291173rightwards.
    12301174 
    1231 XXX: reverse order of row,col args?
    1232  
    12331175XXX: Input row/col are in image coords.
    12341176 
     
    12371179psF32 findValue(psSource *source,
    12381180                psF32 level,
     1181                psU32 col,
    12391182                psU32 row,
    1240                 psU32 col,
    12411183                psU32 dir)
    12421184{
     
    12571199    }
    12581200
    1259     psF32 oldValue = evalModel(source, subRow, subCol);
     1201    psF32 oldValue = evalModel(source, subCol, subRow);
    12601202    if (oldValue == level) {
    12611203        return(((psF32) (subCol + source->pixels->col0)));
     
    12781220
    12791221    while (subCol != lastColumn) {
    1280         psF32 newValue = evalModel(source, subRow, subCol);
     1222        psF32 newValue = evalModel(source, subCol, subRow);
    12811223        if (oldValue == level) {
    12821224            return((psF32) (subCol + source->pixels->col0));
     
    13381280
    13391281        // 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);
    13411283        if (isnan(leftIntercept)) {
    13421284            psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
     
    13491291        // Starting at peak pixel, search rightwards for the column intercept.
    13501292
    1351         psF32 rightIntercept = findValue(source, level, row, col, 1);
     1293        psF32 rightIntercept = findValue(source, level, col, row, 1);
    13521294        if (isnan(rightIntercept)) {
    13531295            psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
     
    13721314
    13731315        // 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);
    13751317        if (isnan(leftIntercept)) {
    13761318            psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
     
    13821324
    13831325        // 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);
    13851327        if (isnan(rightIntercept)) {
    13861328            psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
Note: See TracChangeset for help on using the changeset viewer.