# pgmkernel - generate a convolution kernel - man(1) - [phpMan]

> **TLDR:** Generate a convolution kernel to be used with `pnmconvol`.
>
- Generate a convolution kernel:
  `pgmkernel {{width}} {{height}} > {{path/to/output.pgm}}`
- Generate a quadratic convolution kernel:
  `pgmkernel {{size}} > {{path/to/output.pgm}}`
- Specify the weight of the center in the generated kernel:
  `pgmkernel {{-w|-weight}} {{value}} {{width}} {{height}} > {{path/to/output.pgm}}`

*Source: tldr-pages*

---

_Pgmkernel_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)               General Commands Manual              _Pgmkernel_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)

## NAME
       pgmkernel - generate a convolution kernel


## SYNOPSIS
       **pgmkernel **[**-weight=_**number_] [**-maxval=**] {_size_ | _width_ _height_}

       Minimum  unique  abbreviation of option is acceptable.  You may use double hyphens instead of
       single hyphen to denote options.  You may use white space in place of the equals sign to sep‐
       arate an option name from its value.



## DESCRIPTION
       This program is part of [**Netpbm**(1)](https://www.chedong.com/phpMan.php/man/Netpbm/1/markdown).

       **pgmkernel **generates a convolution kernel that you can use with **pnmconvol**.  The kernel is  one
       where  the  weight of each location is inversely proportional to its distance from the center
       of the kernel.

       **pgmkernel **generates a PGM image of width and height _size_ if  you  specify  one  argument,  or
       width _width_ and height _height_ if you specify two arguments.

       **pgmkernel **computes the convolution function K as follows.

              K(i,j) = 1 / ( 1 + w * sqrt(i^2 + j^2))

       where  _w_  is a coefficient specified via the **-weight **option.  _i_ and _j_ are measured in pixels.
       K is zero everywhere beyond the specified kernel width and height.

       The sample values in the PGM output have this value scaled and biased using the protocol **pnm‐**
       **convol **specifies for representing the real numbers K in PGM.



## OPTIONS
       In addition to the options common to all programs based on libnetpbm  (most  notably  **-quiet**,
       see [ Common Options](index.html#commonoptions) ), **pgmkernel **recognizes the following command line options:



### -weight=_
              The  distance  from  the  center  is weighted by this; a higher number means the value
              falls off more quickly as you go away from the center.

              This must be a positive real number.

              The default is 6.0.


### -maxval=_
              The maxval for the PGM kernel.

              Default is 255.

              This option was new in Netpbm 10.65 (December 2013).  Before that, the maxval  is  al‐
              ways 255.





## LIMITATIONS
       The  computation  time  is proportional to _width_*_height_.  This increases rapidly with the in‐
       crease of the kernel size.  A better approach could be using a FFT in these cases.


## HISTORY
       Before Netpbm 10.65 (December 2013), the output was always in Plain (text) PGM format.  (Now,
       like standard Netpbm programs, the default is raw PGM and you can get Plain PGM with a **-plain**
       option).

       Before Netpbm 10.65 (December 2013), this manual said negative values for **-weight **were  valid
       (as long as they were greater than -1.0).  But the program never worked with negative numbers
       and it isn't clear that the result would be useful, so **-weight **is now required to be nonnega‐
       tive and the program fails gracefully if you specify a negative value.


## SEE ALSO
       [**pnmconvol**(1)](https://www.chedong.com/phpMan.php/man/pnmconvol/1/markdown), [**pnmsmooth**(1)](https://www.chedong.com/phpMan.php/man/pnmsmooth/1/markdown) [**pamgauss**(1)](https://www.chedong.com/phpMan.php/man/pamgauss/1/markdown) [**pgm**(1)](https://www.chedong.com/phpMan.php/man/pgm/1/markdown)



## AUTHOR
       Alberto Accomazzi (<_alberto@cfa.harvard.edu_>).

## DOCUMENT SOURCE
       This  manual  page  was  generated by the Netpbm tool 'makeman' from HTML source.  The master
       documentation is at

              **<http://netpbm.sourceforge.net/doc/pgmkernel.html>**

netpbm documentation                      19 December 2013                  _Pgmkernel_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)
