Index: /trunk/psphot/src/psphot.h
===================================================================
--- /trunk/psphot/src/psphot.h	(revision 11582)
+++ /trunk/psphot/src/psphot.h	(revision 11583)
@@ -101,2 +101,3 @@
 bool psphotLoadExtSources (pmConfig *config, pmFPAview *view, psArray *sources);
 psExit psphotGetExitStatus ();
+bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources);
Index: /trunk/psphot/src/psphotOutput.c
===================================================================
--- /trunk/psphot/src/psphotOutput.c	(revision 11582)
+++ /trunk/psphot/src/psphotOutput.c	(revision 11583)
@@ -92,4 +92,20 @@
 
     psFree (photcode);
+    return true;
+}
+
+bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources) {
+
+    int nSrc = 0;
+
+    // count the number of sources which will be written
+    for (int i = 0; i < sources->n; i++) {
+        pmSource *source = (pmSource *) sources->data[i];
+        pmModel *model = pmSourceSelectModel (source);
+        if (model == NULL)
+            continue;
+        nSrc ++;
+    }
+    psMetadataAdd (recipe, PS_LIST_TAIL, "NSTARS", PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", nSrc);
     return true;
 }
@@ -121,4 +137,5 @@
     psMetadataAdd (header, PS_LIST_TAIL, "FSATUR",   PS_DATA_F32 | PS_META_REPLACE, "SATURATION MAG",      0.0);
     psMetadataAdd (header, PS_LIST_TAIL, "FLIMIT",   PS_DATA_F32 | PS_META_REPLACE, "COMPLETENESS MAG",    0.0);
+    psMetadataItemTransfer (header, recipe, "NSTARS");
 
     // sky background model statistics
Index: /trunk/psphot/src/psphotReadoutCleanup.c
===================================================================
--- /trunk/psphot/src/psphotReadoutCleanup.c	(revision 11582)
+++ /trunk/psphot/src/psphotReadoutCleanup.c	(revision 11583)
@@ -28,4 +28,7 @@
     }
 
+    // write NSTARS to the image header
+    psphotSetHeaderNstars (recipe, sources);
+
     // create an output header with stats results
     psMetadata *header = psphotDefineHeader (recipe);
