Index: /trunk/psModules/src/pmObjects.c
===================================================================
--- /trunk/psModules/src/pmObjects.c	(revision 3722)
+++ /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);
     }
 
Index: /trunk/psModules/test/tst_pmObjects01.c
===================================================================
--- /trunk/psModules/test/tst_pmObjects01.c	(revision 3722)
+++ /trunk/psModules/test/tst_pmObjects01.c	(revision 3723)
@@ -19,6 +19,6 @@
  * abd never deallocate, no error is generated.
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 22:58:48 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 23:44:54 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -479,8 +479,8 @@
 {
     printf("-------------- Calling test_pmFindVectorPeaks on an %d-by-%d image. --------------\n", numRows, numCols);
-    if ((numRows < 4) || (numCols < 4)) {
-        printf("WARNING: Don't call this test with a smaller than 4-by-4 image.\n");
-        return(true);
-    }
+    //    if ((numRows < 4) || (numCols < 4)) {
+    //        printf("WARNING: Don't call this test with a smaller than 4-by-4 image.\n");
+    //        return(true);
+    //    }
     bool testStatus = true;
     psImage *inData = psImageAlloc(numCols, numRows, PS_TYPE_F32);
@@ -523,9 +523,18 @@
         testStatus = false;
     } else {
-        if (outData->size != 5) {
-            printf("TEST ERROR: pmFindImagePeaks found %d peaks (should be 4)\n", outData->size);
-            testStatus = false;
-        }
-
+        psS32 expectedNumPeaks;
+        if ((numRows == 1) && (numCols == 1)) {
+            expectedNumPeaks = 1;
+        } else if ((numRows == 1) || (numCols == 1)) {
+            expectedNumPeaks = 3;
+        } else {
+            expectedNumPeaks = 5;
+        }
+        if (outData->size != expectedNumPeaks) {
+            printf("TEST ERROR: pmFindImagePeaks found %d peaks (should be %d)\n", outData->size, expectedNumPeaks);
+            testStatus = false;
+        }
+
+        // HEY
         psListElem *tmpPeakLE = (psListElem *) outData->head;
         while (tmpPeakLE != NULL) {
@@ -537,10 +546,10 @@
                 if (!(tmpPeak->class & PM_PEAK_LONE) ||
                         !(tmpPeak->class & PM_PEAK_EDGE)) {
-                    printf("TEST ERROR: peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class);
+                    printf("TEST ERROR: (0) peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class);
                     testStatus = false;
                 }
             } else if ((tmpPeak->x == numCols/2) && (tmpPeak->y == numRows/2)) {
                 if (!(tmpPeak->class & PM_PEAK_LONE)) {
-                    printf("TEST ERROR: peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class);
+                    printf("TEST ERROR: (1) peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class);
                     testStatus = false;
                 }
@@ -599,4 +608,7 @@
     //    testStatus&= test_pmFindImagePeaks(5, 2);
     // HEY
+    testStatus&= test_pmFindImagePeaks(1, 1);
+    testStatus&= test_pmFindImagePeaks(1, 8);
+    testStatus&= test_pmFindImagePeaks(8, 1);
     testStatus&= test_pmFindImagePeaks(TST02_NUM_ROWS,   TST02_NUM_COLS);
     testStatus&= test_pmFindImagePeaks(2*TST02_NUM_ROWS, TST02_NUM_COLS);
