Index: trunk/ppSub/src/ppSubReadout.c
===================================================================
--- trunk/ppSub/src/ppSubReadout.c	(revision 14650)
+++ trunk/ppSub/src/ppSubReadout.c	(revision 14673)
@@ -52,4 +52,11 @@
     const char *stampsName = psMetadataLookupStr(&mdok, config->arguments, "STAMPS"); // Filename for stamps
 
+    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
+
     // Generate masks if they don't exist
     int numCols = input->numCols, numRows = input->numRows; // Image dimensions
@@ -71,12 +78,17 @@
     }
 
+    psVector *optWidths = NULL;         // Vector with FWHMs for optimum search
+    if (optimum) {
+        optWidths = psVectorCreate(optWidths, optMin, optMax, optStep, PS_TYPE_F32);
+    }
+
     if (!pmSubtractionMatch(outRO, refRO, inRO, footprint, regionSize, spacing, threshold, stampsName,
-                            NAN, type, size, order, widths, orders, inner, ringsOrder, binning, iter,
-                            rej, maskBad, maskBlank)) {
+                            NAN, 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.");
         psFree(outRO);
         return false;
     }
-
+    psFree(optWidths);
 
     // Add kernel descrption to header
