about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-09-22 16:16:36 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-09-22 16:16:36 +0000
commit6ab48c2924e4db063bdf0073ebf52bae6545eb2c (patch)
tree9cae1df940887e6cb2320fffe12532a9f65085af
parent85512739f7e22aacbca07f6dae877b3c7d3efe12 (diff)
downloadnetpbm-mirror-6ab48c2924e4db063bdf0073ebf52bae6545eb2c.tar.gz
netpbm-mirror-6ab48c2924e4db063bdf0073ebf52bae6545eb2c.tar.xz
netpbm-mirror-6ab48c2924e4db063bdf0073ebf52bae6545eb2c.zip
Fix reversed sense of -nooffset
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1298 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY3
-rw-r--r--editor/pnmconvol.c32
2 files changed, 24 insertions, 11 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 23659bf3..72d41a12 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -23,6 +23,9 @@ not yet  BJH  Release 10.52.00
               still work in legacy code because long is always at least 32
               bits).
 
+              pnmconvol: fix reversed sense of -nooffset.  Introduced in
+              10.49.
+
               ppmtompeg: fix crash with free of unallocated memory.
               Broken after 10.18, not later than 10.26.
 
diff --git a/editor/pnmconvol.c b/editor/pnmconvol.c
index c29a6fe4..14c4ca48 100644
--- a/editor/pnmconvol.c
+++ b/editor/pnmconvol.c
@@ -455,13 +455,13 @@ static void
 convKernelCreatePnm(struct pam *         const cpamP,
                     tuple * const *      const ctuples, 
                     unsigned int         const depth,
-                    bool                 const offsetPgm,
+                    bool                 const offsetPnm,
                     struct convKernel ** const convKernelPP) {
 /*----------------------------------------------------------------------------
-   Compute the convolution matrix in normalized form from the PGM
-   form.  Each element of the output matrix is the actual weight we give an
-   input pixel -- i.e. the thing by which we multiple a value from the
-   input image.
+   Compute the convolution matrix in normalized form from the PGM form
+   'ctuples'/'cpamP'.  Each element of the output matrix is the actual weight
+   we give an input pixel -- i.e. the thing by which we multiple a value from
+   the input image.
 
    'depth' is the required number of planes in the kernel.  If 'ctuples' has
    fewer planes than that, we duplicate as necessary.  E.g. if 'ctuples' is
@@ -470,13 +470,13 @@ convKernelCreatePnm(struct pam *         const cpamP,
    'ctuples' has more planes than specified, we ignore the higher numbered
    ones.
 
-   'offsetPgm' means the PGM convolution matrix is defined in offset form so
+   'offsetPnm' means the PNM convolution matrix is defined in offset form so
    that it can represent negative values.  E.g. with maxval 100, 50 means
    0, 100 means 50, and 0 means -50.  If 'offsetPgm' is false, 0 means 0
    and there are no negative weights.
 -----------------------------------------------------------------------------*/
-    double const scale = (offsetPgm ? 2.0 : 1.0) / cpamP->maxval;
-    double const offset = offsetPgm ? - 1.0 : 0.0;
+    double const scale = (offsetPnm ? 2.0 : 1.0) / cpamP->maxval;
+    double const offset = offsetPnm ? - 1.0 : 0.0;
     unsigned int const planes = MIN(3, depth);
 
     struct convKernel * convKernelP;
@@ -579,9 +579,19 @@ normalizeKernel(struct convKernel * const convKernelP) {
 static void
 getKernelPnm(const char *         const fileName,
              unsigned int         const depth,
-             bool                 const nooffset,
+             bool                 const offset,
              struct convKernel ** const convKernelPP) {
+/*----------------------------------------------------------------------------
+   Get the convolution kernel from the PNM file named 'fileName'.
+   'offset' means the PNM convolution matrix is defined in offset form so
+   that it can represent negative values.  E.g. with maxval 100, 50 means
+   0, 100 means 50, and 0 means -50.  If 'offsetPgm' is false, 0 means 0
+   and there are no negative weights.
+
+   Make the kernel suitable for convolving an image of depth 'depth'.
 
+   Return the kernel as *convKernelPP.
+-----------------------------------------------------------------------------*/
     struct pam cpam;
     FILE * cifP;
     tuple ** ctuples;
@@ -594,7 +604,7 @@ getKernelPnm(const char *         const fileName,
     
     validateKernelDimensions(cpam.width, cpam.height);
 
-    convKernelCreatePnm(&cpam, ctuples, depth, nooffset, convKernelPP);
+    convKernelCreatePnm(&cpam, ctuples, depth, offset, convKernelPP);
 }
 
 
@@ -893,7 +903,7 @@ getKernel(struct cmdlineInfo   const cmdline,
     struct convKernel * convKernelP;
 
     if (cmdline.pnmMatrixFileName)
-        getKernelPnm(cmdline.pnmMatrixFileName, depth, cmdline.nooffset,
+        getKernelPnm(cmdline.pnmMatrixFileName, depth, !cmdline.nooffset,
                      &convKernelP);
     else if (cmdline.matrixfile)
         convKernelCreateSimpleFile(cmdline.matrixfile, cmdline.normalize,