Index: trunk/psModules/src/imcombine/pmSubtractionStamps.h
===================================================================
--- trunk/psModules/src/imcombine/pmSubtractionStamps.h	(revision 14701)
+++ trunk/psModules/src/imcombine/pmSubtractionStamps.h	(revision 14801)
@@ -15,4 +15,38 @@
 } pmSubtractionStampStatus;
 
+/// A list of stamps
+typedef struct {
+    long num;                           ///< Number of stamps
+    psArray *stamps;                    ///< The stamps
+    psArray *regions;                   ///< Regions for each stamp
+    psArray *x, *y;                     ///< Coordinates for possible stamps (or NULL)
+    psArray *flux;                      ///< Fluxes for possible stamps (or NULL)
+} pmSubtractionStampList;
+
+/// Allocate a list of stamps
+pmSubtractionStampList *pmSubtractionStampListAlloc(int numCols, // Number of columns in image
+                                                    int numRows, // Number of rows in image
+                                                    const psRegion *region, // Region for stamps, or NULL
+                                                    float spacing // Rough average spacing between stamps
+    );
+
+/// Assertion for stamp list to be valid
+#define PM_ASSERT_SUBTRACTION_STAMP_LIST_NON_NULL(LIST, RETURNVALUE) { \
+    PS_ASSERT_PTR_NON_NULL(LIST, RETURNVALUE); \
+    PS_ASSERT_ARRAY_NON_NULL((LIST)->stamps, RETURNVALUE); \
+    PS_ASSERT_ARRAY_NON_NULL((LIST)->regions, RETURNVALUE); \
+    PS_ASSERT_INT_POSITIVE((LIST)->num, RETURNVALUE); \
+    PS_ASSERT_ARRAY_SIZE((LIST)->stamps, (LIST)->num, RETURNVALUE); \
+    PS_ASSERT_ARRAY_SIZE((LIST)->regions, (LIST)->num, RETURNVALUE); \
+    if ((LIST)->x || (LIST)->y || (LIST)->flux) { \
+        PS_ASSERT_ARRAY_NON_NULL((LIST)->x, RETURNVALUE); \
+        PS_ASSERT_ARRAY_NON_NULL((LIST)->y, RETURNVALUE); \
+        PS_ASSERT_ARRAY_NON_NULL((LIST)->flux, RETURNVALUE); \
+        PS_ASSERT_ARRAY_SIZE((LIST)->x, (LIST)->num, RETURNVALUE); \
+        PS_ASSERT_ARRAY_SIZE((LIST)->y, (LIST)->num, RETURNVALUE); \
+        PS_ASSERT_ARRAY_SIZE((LIST)->flux, (LIST)->num, RETURNVALUE); \
+    } \
+}
+
 /// A stamp for image subtraction
 typedef struct {
@@ -26,26 +60,35 @@
     psImage *matrix;                    ///< Associated matrix
     psVector *vector;                   ///< Assoicated vector
-    pmSubtractionStampStatus status;    ///< Status ofstamp
+    pmSubtractionStampStatus status;    ///< Status of stamp
 } pmSubtractionStamp;
 
+/// Allocate a stamp
+pmSubtractionStamp *pmSubtractionStampAlloc(void);
+
 /// Find stamps on an image
-psArray *pmSubtractionFindStamps(psArray *stamps, ///< Output stamps, or NULL
-                                 const psImage *image, ///< Image for which to find stamps
-                                 const psImage *mask, ///< Mask, or NULL
-                                 const psRegion *region, ///< Region in which to search for stamps, or NULL
-                                 float threshold, ///< Threshold for stamps in the image
-                                 float spacing ///< Rough spacing for stamps
+pmSubtractionStampList *pmSubtractionFindStamps(pmSubtractionStampList *stamps, ///< Output stamps, or NULL
+                                                const psImage *image, ///< Image for which to find stamps
+                                                const psImage *mask, ///< Mask, or NULL
+                                                const psRegion *region, ///< Region to search, or NULL
+                                                float threshold, ///< Threshold for stamps in the image
+                                                float spacing ///< Rough spacing for stamps
     );
 
 /// Set stamps based on a list of x,y
-psArray *pmSubtractionSetStamps(const psVector *x, ///< x coordinates for each stamp
-                                const psVector *y, ///< y coordinates for each stamp
-                                const psVector *flux, ///< Flux for each stamp, or NULL
-                                const psImage *mask, ///< Mask, or NULL
-                                const psRegion *region ///< Region in which to search for stamps, or NULL
+///
+/// We may optionally apply an exclusion zone around each star --- this is important when we're convolving to
+/// a specified PSF; less so when we're only trying to get a good subtraction.
+pmSubtractionStampList *pmSubtractionSetStamps(const psVector *x, ///< x coordinates for each stamp
+                                               const psVector *y, ///< y coordinates for each stamp
+                                               const psVector *flux, ///< Flux for each stamp, or NULL
+                                               const psImage *image, ///< Image for flux of stamp
+                                               const psImage *mask, ///< Mask, or NULL
+                                               const psRegion *region, ///< Region to search, or NULL
+                                               float spacing, ///< Rough spacing for stamps
+                                               int exclusionZone // Exclusion zone around each star
     );
 
 /// Extract stamps from the images
-bool pmSubtractionExtractStamps(psArray *stamps, ///< Stamps
+bool pmSubtractionExtractStamps(pmSubtractionStampList *stamps, ///< Stamps
                                 psImage *reference, ///< Reference image
                                 psImage *input, ///< Input image (or NULL)
@@ -56,5 +99,5 @@
 
 /// Generate target for stamps based on list
-bool pmSubtractionGenerateStamps(psArray *stamps, ///< Stamps
+bool pmSubtractionGenerateStamps(pmSubtractionStampList *stamps, ///< Stamps
                                  float fwhm, ///< FWHM for each stamp
                                  int footprint, ///< Stamp footprint size
