Index: trunk/ppStack/src/ppStackMatch.c
===================================================================
--- trunk/ppStack/src/ppStackMatch.c	(revision 14626)
+++ trunk/ppStack/src/ppStackMatch.c	(revision 14763)
@@ -14,4 +14,5 @@
 {
     // Look up appropriate values from the ppSub recipe
+    bool mdok;                          // Status of MD lookup
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe
     int size = psMetadataLookupS32(NULL, recipe, "KERNEL.SIZE"); // Kernel half-size
@@ -34,4 +35,10 @@
     psMaskType maskBlank = pmConfigMask(psMetadataLookupStr(NULL, recipe, "MASK.BLANK"),
                                         config); // Mask for blank reg.
+    bool optimum = psMetadataLookupBool(&mdok, config->arguments, "OPTIMUM"); // Derive optimum parameters?
+    float optMin = psMetadataLookupF32(&mdok, config->arguments, "OPTIMUM.MIN"); // Minimum width for search
+    float optMax = psMetadataLookupF32(&mdok, config->arguments, "OPTIMUM.MAX"); // Maximum width for search
+    float optStep = psMetadataLookupF32(&mdok, config->arguments, "OPTIMUM.STEP"); // Step for search
+    float optThresh = psMetadataLookupF32(&mdok, config->arguments, "OPTIMUM.TOL"); // Tolerance for search
+    int optOrder = psMetadataLookupS32(&mdok, config->arguments, "OPTIMUM.ORDER"); // Order for search
 
     // These values are specified specifically for stacking
@@ -39,8 +46,13 @@
     float target = psMetadataLookupF32(NULL, config->arguments, "TARGET"); // Target PSF width
 
+    psVector *optWidths = NULL;         // Vector with FWHMs for optimum search
+    if (optimum) {
+        optWidths = psVectorCreate(optWidths, optMin, optMax, optStep, PS_TYPE_F32);
+    }
+
     // Do the image matching
     if (!pmSubtractionMatch(output, input, NULL, footprint, regionSize, spacing, threshold, stampsName,
-                            target, type, size, order, widths, orders, inner, ringsOrder, binning, iter,
-                            rej, maskBad, maskBlank)) {
+                            target, type, size, order, widths, orders, inner, ringsOrder, binning, optimum,
+                            optWidths, optOrder, optThresh, iter, rej, maskBad, maskBlank)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to match images.");
         return false;
