Index: /trunk/psModules/src/pmObjects.c
===================================================================
--- /trunk/psModules/src/pmObjects.c	(revision 3697)
+++ /trunk/psModules/src/pmObjects.c	(revision 3698)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-14 00:16:39 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-14 02:07:10 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -117,14 +117,13 @@
 
 /******************************************************************************
-XXX: We don't free pixels and mask since that caused a memory error.
-We might need to increase the reference counter and decrease it here.
- *****************************************************************************/
-static void p_psSourceFree(psSource *tmp)
-{
-    psFree(tmp->peak);
-    psFree(tmp->pixels);
-    psFree(tmp->mask);
-    psFree(tmp->moments);
-    psFree(tmp->models);
+p_psSourceFree(tmp): a private function which frees the psSource struct.
+ *****************************************************************************/
+static void p_psSourceFree(psSource *tmpSrc)
+{
+    psFree(tmpSrc->peak);
+    psFree(tmpSrc->pixels);
+    psFree(tmpSrc->mask);
+    psFree(tmpSrc->moments);
+    psFree(tmpSrc->models);
 }
 
@@ -135,13 +134,13 @@
 psSource *pmSourceAlloc()
 {
-    psSource *tmp = (psSource *) psAlloc(sizeof(psSource));
-    tmp->peak = NULL;
-    tmp->pixels = NULL;
-    tmp->mask = NULL;
-    tmp->moments = NULL;
-    tmp->models = NULL;
-    psMemSetDeallocator(tmp, (psFreeFcn) p_psSourceFree);
-
-    return(tmp);
+    psSource *tmpSrc = (psSource *) psAlloc(sizeof(psSource));
+    tmpSrc->peak = NULL;
+    tmpSrc->pixels = NULL;
+    tmpSrc->mask = NULL;
+    tmpSrc->moments = NULL;
+    tmpSrc->models = NULL;
+    psMemSetDeallocator(tmpSrc, (psFreeFcn) p_psSourceFree);
+
+    return(tmpSrc);
 }
 
@@ -155,5 +154,6 @@
 XXX: We currently step through the input vector twice; once to determine the
 size of the output vector, then to set the values of the output vector.
-Depending upon actual use, this may need to be optimized.
+Depending upon actual use, this may need to be optimized.  Use the function
+which adds to a psVector.  It's not clear which way is faster.
  *****************************************************************************/
 psVector *pmFindVectorPeaks(const psVector *vector,
@@ -250,4 +250,6 @@
  
 XXX: Is there a better way to do this?
+ 
+XXX: Use memcpy() on the data transfer.
  *****************************************************************************/
 psVector *p_psGetRowVectorFromImage(psImage *image,
@@ -265,12 +267,31 @@
 
 /******************************************************************************
+p_psGetColVectorFromImage(): a private function which simply returns a
+psVector containing the specified col of data from the psImage.
+ 
+XXX: Is there a better way to do this?
+ 
+XXX: Use memcpy() on the data transfer.
+ *****************************************************************************/
+psVector *p_psGetColVectorFromImage(psImage *image,
+                                    psU32 col)
+{
+    PS_IMAGE_CHECK_NULL(image, NULL);
+    PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, NULL);
+
+    psVector *tmpVector = psVectorAlloc(image->numRows, PS_TYPE_F32);
+    for (psU32 row = 0; row < image->numRows ; row++) {
+        tmpVector->data.F32[row] = image->data.F32[row][col];
+    }
+    return(tmpVector);
+}
+
+/******************************************************************************
 MyListAddPeak(): A private function which allocates a psList, if the list
 argument is NULL, otherwise it adds the peak to that list.
- 
-XXX: Switch row, col args?
  *****************************************************************************/
 psList *MyListAddPeak(psList *list,
+                      psS32 col,
                       psS32 row,
-                      psS32 col,
                       psF32 counts,
                       psPeakType type)
@@ -332,5 +353,5 @@
                     (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
                 if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
                 }
             }
@@ -342,5 +363,5 @@
                     (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
                 if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
                 }
             }
@@ -351,5 +372,5 @@
                     (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) {
                 if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
                 }
             }
@@ -386,5 +407,5 @@
                         (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
                     myType = PM_PEAK_EDGE;
-                    list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
                 }
             } else if (col < (image->numCols - 1)) {
@@ -421,5 +442,5 @@
                         }
 
-                        list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);
+                        list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
                     }
                 }
@@ -433,5 +454,5 @@
                         (image->data.F32[row][col] >= image->data.F32[row+1][col])) {
                     myType = PM_PEAK_EDGE;
-                    list = MyListAddPeak(list, row, col, image->data.F32[row][col], myType);
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
                 }
             } else {
@@ -455,5 +476,5 @@
                     (image->data.F32[row][col] >  image->data.F32[row][col+1])) {
                 if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
                 }
             }
@@ -465,5 +486,5 @@
                     (image->data.F32[row][col] >= image->data.F32[row][col+1])) {
                 if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
                 }
             }
@@ -474,5 +495,5 @@
                     (image->data.F32[row][col] >  image->data.F32[row][col-1])) {
                 if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
                 }
             }
@@ -484,4 +505,11 @@
     return(list);
 }
+
+
+#define PS_REGION_CHECK(VALID, X, Y) \
+(((X) >= (VALID)->x0) && \
+ ((X) <= (VALID)->x1) && \
+ ((Y) >= (VALID)->y0) && \
+ ((Y) <= (VALID)->y1))
 
 // XXX: Macro this.
@@ -525,5 +553,6 @@
         if ((tmpPeak->counts > maxValue) ||
                 ((valid != NULL) &&
-                 (true == IsItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {
+                 //                 (true == IsItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {
+                 (true == PS_REGION_CHECK(valid, tmpPeak->x, tmpPeak->y)))) {
             psListRemoveData(peaks, (psPtr) tmpPeak);
         }
