Index: trunk/psModules/src/pmObjects.c
===================================================================
--- trunk/psModules/src/pmObjects.c	(revision 3717)
+++ trunk/psModules/src/pmObjects.c	(revision 3723)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 22:58:48 $
+ *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 23:44:54 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -312,9 +312,5 @@
 above the given threshold.  Returns a psList containing location (x/y value)
 of all peaks.
- 
-XXX: For multiple type peaks, ensure that each is set.
- 
-XXX: This does not work if image has either a single row, or a single column.
-  *****************************************************************************/
+ *****************************************************************************/
 psList *pmFindImagePeaks(const psImage *image,
                          psF32 threshold)
@@ -322,7 +318,4 @@
     PS_IMAGE_CHECK_NULL(image, NULL);
     PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, NULL);
-    if ((image->numRows == 1) || (image->numCols == 1)) {
-        psError(PS_ERR_UNKNOWN, true, "Currently, input image must have at least 2 rows and 2 columns.");
-    }
     psPeakType myPeakClass = PM_PEAK_UNDEF;
     psVector *tmpRow = NULL;
@@ -332,5 +325,140 @@
 
     //
-    // Find peaks in row 0 only.
+    // Special case: a 1-by-1 image.
+    //
+    if ((image->numCols == 1) && (image->numRows == 1)) {
+        if (image->data.F32[row][col] > threshold) {
+            myPeakClass = PM_PEAK_EDGE | PM_PEAK_LONE;
+            list = MyListAddPeak(list, 0, 0, image->data.F32[row][col], myPeakClass);
+            return(list);
+        } else {
+            return(NULL);
+        }
+    }
+
+    //
+    // Find peaks in row 0 only (single-row image).  This is a special case since
+    // we can not test data at image->data.F32[row+1][...])
+    //
+    if (image->numRows == 1) {
+        row = 0;
+        tmpRow = p_psGetRowVectorFromImage((psImage *) image, row);
+        psVector *row1 = pmFindVectorPeaks(tmpRow, threshold);
+        for (psU32 i = 0 ; i < row1->n ; i++ ) {
+            col = row1->data.U32[i];
+            //
+            // Determine if pixel (0,0) is a peak.
+            //
+            if (col == 0) {
+                if ( (image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >  image->data.F32[row][col+1])) {
+                    myPeakClass = PM_PEAK_EDGE | PM_PEAK_LONE;
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
+                }
+            } else if (col < (image->numCols - 1)) {
+
+                if ( (image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >= image->data.F32[row][col-1]) &&
+                        (image->data.F32[row][col] >  image->data.F32[row][col+1])) {
+                    myPeakClass = PM_PEAK_EDGE;
+
+                    if (image->data.F32[row][col] > image->data.F32[row][col-1]) {
+                        myPeakClass|= PM_PEAK_LONE;
+                    } else {
+                        myPeakClass|= PM_PEAK_FLAT;
+                    }
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
+                }
+
+            } else if (col == (image->numCols - 1)) {
+                if ( (image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >= image->data.F32[row][col-1])) {
+                    myPeakClass = PM_PEAK_EDGE;
+
+                    if (image->data.F32[row][col] > image->data.F32[row][col-1]) {
+                        myPeakClass|= PM_PEAK_LONE;
+                    } else {
+                        myPeakClass|= PM_PEAK_FLAT;
+                    }
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
+                }
+            } else {
+                psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range.");
+            }
+
+        }
+        //
+        // We exit here since this is a single-row image.
+        //
+        // XXX: Why are we not getting memory leak errors?
+        //
+        //
+        // psFree(tmpRow);
+        // psFree(row1);
+        //
+        return(list);
+    }
+
+    //
+    // Find peaks in col 0 only (single-col image).  This is a special case since
+    // we can not test data at image->data.F32[...][col+1])
+    //
+    if (image->numCols == 1) {
+        col = 0;
+        psVector *tmpCol = p_psGetColVectorFromImage((psImage *) image, col);
+        psVector *col1 = pmFindVectorPeaks(tmpCol, threshold);
+        for (psU32 i = 0 ; i < col1->n ; i++ ) {
+            row = col1->data.U32[i];
+            //
+            // Determine if pixel (0,0) is a peak.
+            //
+            if (row == 0) {
+                if ( (image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >  image->data.F32[row+1][col])) {
+                    myPeakClass = PM_PEAK_EDGE | PM_PEAK_LONE;
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
+                }
+            } else if (row < (image->numRows - 1)) {
+
+                if ( (image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >= image->data.F32[row-1][col]) &&
+                        (image->data.F32[row][col] >  image->data.F32[row+1][col])) {
+                    myPeakClass = PM_PEAK_EDGE;
+
+                    if (image->data.F32[row][col] > image->data.F32[row-1][col]) {
+                        myPeakClass|= PM_PEAK_LONE;
+                    } else {
+                        myPeakClass|= PM_PEAK_FLAT;
+                    }
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
+                }
+
+            } else if (row == (image->numRows - 1)) {
+                if ( (image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >= image->data.F32[row-1][col])) {
+                    myPeakClass = PM_PEAK_EDGE;
+
+                    if (image->data.F32[row][col] > image->data.F32[row-1][col]) {
+                        myPeakClass|= PM_PEAK_LONE;
+                    } else {
+                        myPeakClass|= PM_PEAK_FLAT;
+                    }
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
+                }
+            } else {
+                psError(PS_ERR_UNKNOWN, true, "peak specified outside valid row range.");
+            }
+
+        }
+        //
+        // We exit here since this is a single-column image.
+        //
+        // XXX: free tmpRow col1?
+        //
+        return(list);
+    }
+
+    //
+    // Find peaks in row 0 only (multi-row image).
     //
     row = 0;
@@ -392,10 +520,4 @@
             psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range.");
         }
-    }
-    //
-    // Exit if this image has a single row.
-    //
-    if (image->numRows == 1) {
-        return(list);
     }
 
