IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Cleaned up some comments, added macros.

File:
1 edited

Legend:

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

    r3697 r3698  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-04-14 00:16:39 $
     7 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-04-14 02:07:10 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    117117
    118118/******************************************************************************
    119 XXX: We don't free pixels and mask since that caused a memory error.
    120 We might need to increase the reference counter and decrease it here.
    121  *****************************************************************************/
    122 static void p_psSourceFree(psSource *tmp)
    123 {
    124     psFree(tmp->peak);
    125     psFree(tmp->pixels);
    126     psFree(tmp->mask);
    127     psFree(tmp->moments);
    128     psFree(tmp->models);
     119p_psSourceFree(tmp): a private function which frees the psSource struct.
     120 *****************************************************************************/
     121static void p_psSourceFree(psSource *tmpSrc)
     122{
     123    psFree(tmpSrc->peak);
     124    psFree(tmpSrc->pixels);
     125    psFree(tmpSrc->mask);
     126    psFree(tmpSrc->moments);
     127    psFree(tmpSrc->models);
    129128}
    130129
     
    135134psSource *pmSourceAlloc()
    136135{
    137     psSource *tmp = (psSource *) psAlloc(sizeof(psSource));
    138     tmp->peak = NULL;
    139     tmp->pixels = NULL;
    140     tmp->mask = NULL;
    141     tmp->moments = NULL;
    142     tmp->models = NULL;
    143     psMemSetDeallocator(tmp, (psFreeFcn) p_psSourceFree);
    144 
    145     return(tmp);
     136    psSource *tmpSrc = (psSource *) psAlloc(sizeof(psSource));
     137    tmpSrc->peak = NULL;
     138    tmpSrc->pixels = NULL;
     139    tmpSrc->mask = NULL;
     140    tmpSrc->moments = NULL;
     141    tmpSrc->models = NULL;
     142    psMemSetDeallocator(tmpSrc, (psFreeFcn) p_psSourceFree);
     143
     144    return(tmpSrc);
    146145}
    147146
     
    155154XXX: We currently step through the input vector twice; once to determine the
    156155size of the output vector, then to set the values of the output vector.
    157 Depending upon actual use, this may need to be optimized.
     156Depending upon actual use, this may need to be optimized.  Use the function
     157which adds to a psVector.  It's not clear which way is faster.
    158158 *****************************************************************************/
    159159psVector *pmFindVectorPeaks(const psVector *vector,
     
    250250 
    251251XXX: Is there a better way to do this?
     252 
     253XXX: Use memcpy() on the data transfer.
    252254 *****************************************************************************/
    253255psVector *p_psGetRowVectorFromImage(psImage *image,
     
    265267
    266268/******************************************************************************
     269p_psGetColVectorFromImage(): a private function which simply returns a
     270psVector containing the specified col of data from the psImage.
     271 
     272XXX: Is there a better way to do this?
     273 
     274XXX: Use memcpy() on the data transfer.
     275 *****************************************************************************/
     276psVector *p_psGetColVectorFromImage(psImage *image,
     277                                    psU32 col)
     278{
     279    PS_IMAGE_CHECK_NULL(image, NULL);
     280    PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, NULL);
     281
     282    psVector *tmpVector = psVectorAlloc(image->numRows, PS_TYPE_F32);
     283    for (psU32 row = 0; row < image->numRows ; row++) {
     284        tmpVector->data.F32[row] = image->data.F32[row][col];
     285    }
     286    return(tmpVector);
     287}
     288
     289/******************************************************************************
    267290MyListAddPeak(): A private function which allocates a psList, if the list
    268291argument is NULL, otherwise it adds the peak to that list.
    269  
    270 XXX: Switch row, col args?
    271292 *****************************************************************************/
    272293psList *MyListAddPeak(psList *list,
     294                      psS32 col,
    273295                      psS32 row,
    274                       psS32 col,
    275296                      psF32 counts,
    276297                      psPeakType type)
     
    332353                    (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
    333354                if (image->data.F32[row][col] > threshold) {
    334                     list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     355                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
    335356                }
    336357            }
     
    342363                    (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
    343364                if (image->data.F32[row][col] > threshold) {
    344                     list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     365                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
    345366                }
    346367            }
     
    351372                    (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) {
    352373                if (image->data.F32[row][col] > threshold) {
    353                     list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     374                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
    354375                }
    355376            }
     
    386407                        (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
    387408                    myType = PM_PEAK_EDGE;
    388                     list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);
     409                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
    389410                }
    390411            } else if (col < (image->numCols - 1)) {
     
    421442                        }
    422443
    423                         list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);
     444                        list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
    424445                    }
    425446                }
     
    433454                        (image->data.F32[row][col] >= image->data.F32[row+1][col])) {
    434455                    myType = PM_PEAK_EDGE;
    435                     list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);
     456                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
    436457                }
    437458            } else {
     
    455476                    (image->data.F32[row][col] >  image->data.F32[row][col+1])) {
    456477                if (image->data.F32[row][col] > threshold) {
    457                     list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     478                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
    458479                }
    459480            }
     
    465486                    (image->data.F32[row][col] >= image->data.F32[row][col+1])) {
    466487                if (image->data.F32[row][col] > threshold) {
    467                     list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     488                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
    468489                }
    469490            }
     
    474495                    (image->data.F32[row][col] >  image->data.F32[row][col-1])) {
    475496                if (image->data.F32[row][col] > threshold) {
    476                     list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     497                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
    477498                }
    478499            }
     
    484505    return(list);
    485506}
     507
     508
     509#define PS_REGION_CHECK(VALID, X, Y) \
     510(((X) >= (VALID)->x0) && \
     511 ((X) <= (VALID)->x1) && \
     512 ((Y) >= (VALID)->y0) && \
     513 ((Y) <= (VALID)->y1))
    486514
    487515// XXX: Macro this.
     
    525553        if ((tmpPeak->counts > maxValue) ||
    526554                ((valid != NULL) &&
    527                  (true == IsItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {
     555                 //                 (true == IsItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {
     556                 (true == PS_REGION_CHECK(valid, tmpPeak->x, tmpPeak->y)))) {
    528557            psListRemoveData(peaks, (psPtr) tmpPeak);
    529558        }
Note: See TracChangeset for help on using the changeset viewer.