about summary refs log tree commit diff
path: root/editor/pamthreshold.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-09-11 02:38:48 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-09-11 02:38:48 +0000
commit7bd77004a7a252e5e33309944e04e70dc7fd8c46 (patch)
tree849a3f7d70929bb58046634ae85725362e8e69d6 /editor/pamthreshold.c
parentdc71766e555f84091dc4cff5f2e7634f52f94bda (diff)
downloadnetpbm-mirror-7bd77004a7a252e5e33309944e04e70dc7fd8c46.tar.gz
netpbm-mirror-7bd77004a7a252e5e33309944e04e70dc7fd8c46.tar.xz
netpbm-mirror-7bd77004a7a252e5e33309944e04e70dc7fd8c46.zip
Fast path for local thresholding: don't compute unneeded global stuff
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@53 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pamthreshold.c')
-rw-r--r--editor/pamthreshold.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/editor/pamthreshold.c b/editor/pamthreshold.c
index 40260e79..4caaed9b 100644
--- a/editor/pamthreshold.c
+++ b/editor/pamthreshold.c
@@ -508,9 +508,16 @@ thresholdLocal(struct pam *       const inpamP,
 
     windowHeight = MIN(oddLocalHeight, inpamP->height);
 
-    analyzeDistribution(inpamP, &histogram, &globalRange);
-
-    computeGlobalThreshold(inpamP, histogram, globalRange, &globalThreshold);
+    /* global information is needed for dual thresholding */
+    if (cmdline.dual) {
+        analyzeDistribution(inpamP, &histogram, &globalRange);
+        computeGlobalThreshold(inpamP, histogram, globalRange,
+                               &globalThreshold);
+    } else {
+        histogram = NULL;
+        initRange(&globalRange);
+        globalThreshold = 1.0;
+    }
 
     outrow = pnm_allocpamrow(outpamP);
 
@@ -580,17 +587,17 @@ main(int argc, char **argv) {
 
     parseCommandLine(argc, argv, &cmdline);
 
-    if (cmdline.simple)
+    if (cmdline.simple || cmdline.local)
         ifP = pm_openr(cmdline.inputFileName);
     else
         ifP = pm_openr_seekable(cmdline.inputFileName);
 
-    /* threshold each image in the PAM file */
+    /* Threshold each image in the PAM file */
     eof = FALSE;
     while (!eof) {
         pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
 
-        /* set output image parameters for a bilevel image */
+        /* Set output image parameters for a bilevel image */
         outpam.size        = sizeof(outpam);
         outpam.len         = PAM_STRUCT_SIZE(tuple_type);
         outpam.file        = stdout;
@@ -605,7 +612,7 @@ main(int argc, char **argv) {
 
         pnm_writepaminit(&outpam);
 
-        /* do the thresholding */
+        /* Do the thresholding */
 
         if (cmdline.simple)
             thresholdSimple(&inpam, &outpam, cmdline.threshold);