Index: trunk/ippdb/src/ippdb.c
===================================================================
--- trunk/ippdb/src/ippdb.c	(revision 8528)
+++ trunk/ippdb/src/ippdb.c	(revision 8543)
@@ -14057,5 +14057,5 @@
 static void detStackedImfileRowFree(detStackedImfileRow *object);
 
-detStackedImfileRow *detStackedImfileRowAlloc(psS32 det_id, psS32 iteration, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev)
+detStackedImfileRow *detStackedImfileRowAlloc(psS32 det_id, psS32 iteration, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, bool normalize)
 {
     detStackedImfileRow *object;
@@ -14072,4 +14072,5 @@
     object->bg_stdev = bg_stdev;
     object->bg_mean_stdev = bg_mean_stdev;
+    object->normalize = normalize;
 
     return object;
@@ -14134,4 +14135,9 @@
         return false;
     }
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "normalize", PS_DATA_BOOL, NULL, false)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item normalize");
+        psFree(md);
+        return false;
+    }
 
     status = psDBCreateTable(dbh, DETSTACKEDIMFILE_TABLE_NAME, md);
@@ -14147,5 +14153,5 @@
 }
 
-bool detStackedImfileInsert(psDB * dbh, psS32 det_id, psS32 iteration, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev)
+bool detStackedImfileInsert(psDB * dbh, psS32 det_id, psS32 iteration, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, bool normalize)
 {
     psMetadata      *md;
@@ -14190,4 +14196,9 @@
     if (!psMetadataAddF64(md, PS_LIST_TAIL, "bg_mean_stdev", 0, NULL, bg_mean_stdev)) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev");
+        psFree(md);
+        return false;
+    }
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "normalize", PS_DATA_BOOL, NULL, normalize)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item normalize");
         psFree(md);
         return false;
@@ -14214,5 +14225,5 @@
     return deleted;
 }
-bool detStackedImfilePop(psDB *dbh, psS32 *det_id, psS32 *iteration, char **class_id, char **uri, char **recipe, psF64 *bg, psF64 *bg_stdev, psF64 *bg_mean_stdev)
+bool detStackedImfilePop(psDB *dbh, psS32 *det_id, psS32 *iteration, char **class_id, char **uri, char **recipe, psF64 *bg, psF64 *bg_stdev, psF64 *bg_mean_stdev, bool *normalize)
 {
     psArray         *rowSet;
@@ -14306,4 +14317,10 @@
         return false;
     }
+    *normalize = psMetadataLookupBool(&status, row, "normalize");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item normalize");
+        psFree(row);
+        return false;
+    }
 
     psFree(row);
@@ -14314,5 +14331,5 @@
 bool detStackedImfileInsertObject(psDB *dbh, detStackedImfileRow *object)
 {
-    return detStackedImfileInsert(dbh, object->det_id, object->iteration, object->class_id, object->uri, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev);
+    return detStackedImfileInsert(dbh, object->det_id, object->iteration, object->class_id, object->uri, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->normalize);
 }
 
@@ -14338,11 +14355,12 @@
     psF64           bg_stdev;
     psF64           bg_mean_stdev;
-
-    if (!detStackedImfilePop(dbh, &det_id, &iteration, (char **)&class_id, (char **)&uri, (char **)&recipe, &bg, &bg_stdev, &bg_mean_stdev)) {
+    bool            normalize;
+
+    if (!detStackedImfilePop(dbh, &det_id, &iteration, (char **)&class_id, (char **)&uri, (char **)&recipe, &bg, &bg_stdev, &bg_mean_stdev, &normalize)) {
         psError(PS_ERR_UNKNOWN, false, "failed to pop a database row");
         return NULL;
     }
 
-    return detStackedImfileRowAlloc(det_id, iteration, class_id, uri, recipe, bg, bg_stdev, bg_mean_stdev);
+    return detStackedImfileRowAlloc(det_id, iteration, class_id, uri, recipe, bg, bg_stdev, bg_mean_stdev, normalize);
 }
 
@@ -14480,4 +14498,9 @@
     if (!psMetadataAddF64(md, PS_LIST_TAIL, "bg_mean_stdev", 0, NULL, object->bg_mean_stdev)) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev");
+        psFree(md);
+        return NULL;
+    }
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "normalize", PS_DATA_BOOL, NULL, object->normalize)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item normalize");
         psFree(md);
         return NULL;
@@ -14498,4 +14521,5 @@
     psF64           bg_stdev;
     psF64           bg_mean_stdev;
+    bool            normalize;
 
     det_id = psMetadataLookupS32(&status, md, "det_id");
@@ -14539,6 +14563,11 @@
         return false;
     }
-
-    return detStackedImfileRowAlloc(det_id, iteration, class_id, uri, recipe, bg, bg_stdev, bg_mean_stdev);
+    normalize = psMetadataLookupBool(&status, md, "normalize");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item normalize");
+        return false;
+    }
+
+    return detStackedImfileRowAlloc(det_id, iteration, class_id, uri, recipe, bg, bg_stdev, bg_mean_stdev, normalize);
 }
 psArray *detStackedImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
