IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 19, 2005, 12:58:48 PM (21 years ago)
Author:
gusciora
Message:

Cleaning the code in pmObjects.c, fixing bugs with the allocators and the
vector/image find peaks routines, adding additional tests for these.

File:
1 edited

Legend:

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

    r3701 r3717  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-04-14 03:27:50 $
     7 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-04-19 22:58:48 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4545    tmp->y = 0.0;
    4646    tmp->Sx = 0.0;
    47     tmp->Sx = 0.0;
     47    tmp->Sy = 0.0;
    4848    tmp->Sxy = 0.0;
    4949    tmp->Sum = 0.0;
     
    325325        psError(PS_ERR_UNKNOWN, true, "Currently, input image must have at least 2 rows and 2 columns.");
    326326    }
     327    psPeakType myPeakClass = PM_PEAK_UNDEF;
    327328    psVector *tmpRow = NULL;
    328329    psU32 col = 0;
     
    343344        //
    344345        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]) &&
    346348                    (image->data.F32[row][col] >  image->data.F32[row+1][col]) &&
    347349                    (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;
    350355                }
     356                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
    351357            }
    352358        } 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]) &&
    354361                    (image->data.F32[row][col] >  image->data.F32[row][col+1]) &&
    355362                    (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
    356363                    (image->data.F32[row][col] >  image->data.F32[row+1][col]) &&
    357364                    (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;
    360373                }
     374                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
    361375            }
    362376
    363377        } 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]) &&
    365380                    (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
    366381                    (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;
    369388                }
     389                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
    370390            }
    371 
    372391        } else {
    373             psError(PS_ERR_UNKNOWN, true, "peak specified valid column range.");
     392            psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range.");
    374393        }
    375394    }
     
    390409        // Step through all local peaks in this row.
    391410        for (psU32 i = 0 ; i < row1->n ; i++ ) {
    392             psPeakType myType = PM_PEAK_UNDEF;
    393411            col = row1->data.U32[i];
    394412
    395413            if (col == 0) {
    396414                // 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]) &&
    398417                        (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
    399418                        (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&
    400419                        (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&
    401420                        (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);
    404432                }
    405433            } else if (col < (image->numCols - 1)) {
    406434                // 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]) &&
    408437                        (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    409438                        (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
     
    413442                        (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&
    414443                        (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;
    439454                    }
     455
     456                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
    440457                }
    441458            } else if (col == (image->numCols - 1)) {
    442459                // 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]) &&
    444462                        (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    445463                        (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
     
    447465                        (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
    448466                        (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);
    451478                }
    452479            } else {
    453                 psError(PS_ERR_UNKNOWN, true, "peak specified valid column range.");
     480                psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range.");
    454481            }
    455 
    456482        }
    457483    }
     
    466492        col = row1->data.U32[i];
    467493        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]) &&
    469496                    (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
    470497                    (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;
    473504                }
     505
     506                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
    474507            }
    475508        } 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]) &&
    477511                    (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    478512                    (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
    479513                    (image->data.F32[row][col] >  image->data.F32[row][col-1]) &&
    480514                    (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;
    483523                }
     524
     525                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
    484526            }
    485527
    486528        } 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]) &&
    488531                    (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    489532                    (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;
    492539                }
     540
     541                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
    493542            }
    494543        } else {
     
    600649    psS32 SubImageCenterRow = peak->y;
    601650    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);
    606655    // AnulusWidth == number of pixels width in the annulus.  We add one since
    607656    // the pixels at the inner AND outher radius are included.
Note: See TracChangeset for help on using the changeset viewer.