| 1 |
\ |
| 2 |
.\" This man page was generated by the Netpbm tool 'makeman' from HTML source. |
| 3 |
.\" Do not hand-hack it! If you have bug fixes or improvements, please find |
| 4 |
.\" the corresponding HTML page on the Netpbm website, generate a patch |
| 5 |
.\" against that, and send it to the Netpbm maintainer. |
| 6 |
.TH "Pnmnlfilt User Manual" 1 "24 October 2006" "netpbm documentation" |
| 7 |
|
| 8 |
.SH NAME |
| 9 |
|
| 10 |
pnmnlfilt - non-linear filters: smooth, alpha trim mean, optimal |
| 11 |
estimation smoothing, edge enhancement. |
| 12 |
|
| 13 |
.UN synopsis |
| 14 |
.SH SYNOPSIS |
| 15 |
|
| 16 |
\fBpnmnlfilt\fP |
| 17 |
\fIalpha\fP |
| 18 |
\fIradius\fP |
| 19 |
[\fIpnmfile\fP] |
| 20 |
|
| 21 |
.UN description |
| 22 |
.SH DESCRIPTION |
| 23 |
.PP |
| 24 |
This program is part of |
| 25 |
.BR "Netpbm" (1)\c |
| 26 |
\&. |
| 27 |
.PP |
| 28 |
\fBpnmnlfilt\fP produces an output image where the pixels are a |
| 29 |
summary of multiple pixels near the corresponding location in an input |
| 30 |
image. |
| 31 |
.PP |
| 32 |
This program works on multi-image streams. |
| 33 |
.PP |
| 34 |
This is something of a swiss army knife filter. It has 3 distinct |
| 35 |
operating modes. In all of the modes \fBpnmnlfilt\fP examines each |
| 36 |
pixel in the image and processes it according to the values of it and |
| 37 |
its surrounding pixels. Rather than using a square block of |
| 38 |
surrounding pixels (e.g. the subject pixel and its 8 immediate |
| 39 |
neighbors, in a 3x3 square), \fBpnmnlfilt\fP uses 7 hexagonal areas. |
| 40 |
You choose the size of the hexagons with the radius parameter. A |
| 41 |
radius value of 1/3 means that the 7 hexagons essentially fit into the |
| 42 |
subject pixel (ie. there will be no filtering effect). A radius |
| 43 |
value of 1.0 means that the 7 hexagons essentially cover the 3x3 |
| 44 |
immediate neighbor square. |
| 45 |
.PP |
| 46 |
Your choice of "alpha" parameter selects among the three |
| 47 |
modes. |
| 48 |
|
| 49 |
.UN alphatrimmedmean |
| 50 |
.SS |
| 51 |
Alpha trimmed mean filter (0.0 <= alpha <= 0.5) |
| 52 |
.PP |
| 53 |
The value of the center pixel will be replaced by the mean of |
| 54 |
the 7 hexagon values, but the 7 values are sorted by size and the top |
| 55 |
and bottom alpha portion of the 7 are excluded from the mean. This |
| 56 |
implies that an alpha value of 0.0 gives the same sort of output as a |
| 57 |
normal convolution (ie. averaging or smoothing filter), where radius |
| 58 |
will determine the "strength" of the filter. A good value to |
| 59 |
start from for subtle filtering is alpha = 0.0, radius = 0.55 For a |
| 60 |
more blatant effect, try alpha 0.0 and radius 1.0 |
| 61 |
.PP |
| 62 |
An alpha value of 0.5 will cause the median value of the 7 hexagons |
| 63 |
to be used to replace the center pixel value. This sort of filter is |
| 64 |
good for eliminating "pop" or single pixel noise from an |
| 65 |
image without spreading the noise out or smudging features on the |
| 66 |
image. Judicious use of the radius parameter will fine tune the |
| 67 |
filtering. Intermediate values of alpha give effects somewhere between |
| 68 |
smoothing and "pop" noise reduction. For subtle filtering |
| 69 |
try starting with values of alpha = 0.4, radius = 0.6 For a more |
| 70 |
blatant effect try alpha = 0.5, radius = 1.0 |
| 71 |
|
| 72 |
.UN optimalestsmooth |
| 73 |
.SS |
| 74 |
Optimal estimation smoothing. (1.0 <= alpha <= 2.0) |
| 75 |
.PP |
| 76 |
This type of filter applies a smoothing filter adaptively over the |
| 77 |
image. For each pixel the variance of the surrounding hexagon values |
| 78 |
is calculated, and the amount of smoothing is made inversely |
| 79 |
proportional to it. The idea is that if the variance is small then it |
| 80 |
is due to noise in the image, while if the variance is large, it is |
| 81 |
because of "wanted" image features. As usual the radius |
| 82 |
parameter controls the effective radius, but it probably advisable to |
| 83 |
leave the radius between 0.8 and 1.0 for the variance calculation to |
| 84 |
be meaningful. The alpha parameter sets the noise threshold, over |
| 85 |
which less smoothing will be done. This means that small values of |
| 86 |
alpha will give the most subtle filtering effect, while large values |
| 87 |
will tend to smooth all parts of the image. You could start with |
| 88 |
values like alpha = 1.2, radius = 1.0 and try increasing or decreasing |
| 89 |
the alpha parameter to get the desired effect. This type of filter is |
| 90 |
best for filtering out dithering noise in both bitmap and color |
| 91 |
images. |
| 92 |
|
| 93 |
.UN edgeenhance |
| 94 |
.SS Edge enhancement. (-0.1 >= alpha >= -0.9) |
| 95 |
.PP |
| 96 |
This is the opposite type of filter to the smoothing filter. It |
| 97 |
enhances edges. The alpha parameter controls the amount of edge |
| 98 |
enhancement, from subtle (-0.1) to blatant (-0.9). The radius |
| 99 |
parameter controls the effective radius as usual, but useful values |
| 100 |
are between 0.5 and 0.9. Try starting with values of alpha = 0.3, |
| 101 |
radius = 0.8 |
| 102 |
|
| 103 |
.UN combination |
| 104 |
.SS Combination use. |
| 105 |
.PP |
| 106 |
The various modes of \fBpnmnlfilt\fP can be used one after the |
| 107 |
other to get the desired result. For instance to turn a monochrome |
| 108 |
dithered image into a grayscale image you could try one or two passes |
| 109 |
of the smoothing filter, followed by a pass of the optimal estimation |
| 110 |
filter, then some subtle edge enhancement. Note that using edge |
| 111 |
enhancement is only likely to be useful after one of the non-linear |
| 112 |
filters (alpha trimmed mean or optimal estimation filter), as edge |
| 113 |
enhancement is the direct opposite of smoothing. |
| 114 |
.PP |
| 115 |
For reducing color quantization noise in images (ie. turning .gif |
| 116 |
files back into 24 bit files) you could try a pass of the optimal |
| 117 |
estimation filter (alpha 1.2, radius 1.0), a pass of the median filter |
| 118 |
(alpha 0.5, radius 0.55), and possibly a pass of the edge enhancement |
| 119 |
filter. Several passes of the optimal estimation filter with |
| 120 |
declining alpha values are more effective than a single pass with a |
| 121 |
large alpha value. As usual, there is a tradeoff between filtering |
| 122 |
effectiveness and losing detail. Experimentation is encouraged. |
| 123 |
|
| 124 |
.UN options |
| 125 |
.SH OPTIONS |
| 126 |
.PP |
| 127 |
There are no command line options defined specifically |
| 128 |
for \fBpnmnlfilt\fP, but it recognizes the options common to all |
| 129 |
programs based on libnetpbm (See |
| 130 |
.UR index.html#commonoptions |
| 131 |
Common Options |
| 132 |
.UE |
| 133 |
\&.) |
| 134 |
|
| 135 |
.UN references |
| 136 |
.SH REFERENCES |
| 137 |
.PP |
| 138 |
The alpha-trimmed mean filter is based on the description in IEEE |
| 139 |
CG&A May 1990 Page 23 by Mark E. Lee and Richard A. Redner, and |
| 140 |
has been enhanced to allow continuous alpha adjustment. |
| 141 |
.PP |
| 142 |
The optimal estimation filter is taken from an article |
| 143 |
"Converting Dithered Images Back to Gray Scale" by Allen |
| 144 |
Stenger, Dr Dobb's Journal, November 1992, and this article references |
| 145 |
"Digital Image Enhancement and Noise Filtering by Use of Local |
| 146 |
Statistics", Jong-Sen Lee, IEEE Transactions on Pattern Analysis |
| 147 |
and Machine Intelligence, March 1980. |
| 148 |
.PP |
| 149 |
The edge enhancement details are from |
| 150 |
.BR "pgmenhance" (1)\c |
| 151 |
\&, which is taken from Philip |
| 152 |
R. Thompson's "xim" program, which in turn took it from |
| 153 |
section 6 of "Digital Halftones by Dot Diffusion", |
| 154 |
D. E. Knuth, ACM Transaction on Graphics Vol. 6, No. 4, October 1987, |
| 155 |
which in turn got it from two 1976 papers by J. F. Jarvis et. al. |
| 156 |
|
| 157 |
.UN parameters |
| 158 |
.SH PARAMETERS |
| 159 |
.PP |
| 160 |
The parameters are: |
| 161 |
|
| 162 |
|
| 163 |
.TP |
| 164 |
\fIalpha\fP |
| 165 |
The alpha value (described above), in decimal. May be fractional. |
| 166 |
|
| 167 |
.TP |
| 168 |
\fIradius\fP |
| 169 |
The radius (described above), in decimal. May be fractional. |
| 170 |
|
| 171 |
|
| 172 |
.UN seealso |
| 173 |
.SH SEE ALSO |
| 174 |
.BR "pgmenhance" (1)\c |
| 175 |
\&, |
| 176 |
.BR "pnmconvol" (1)\c |
| 177 |
\&, |
| 178 |
.BR "pnm" (1)\c |
| 179 |
\& |
| 180 |
|
| 181 |
.UN author |
| 182 |
.SH AUTHOR |
| 183 |
|
| 184 |
Graeme W. Gill \[email protected]\fP |
| 185 |
.SH DOCUMENT SOURCE |
| 186 |
This manual page was generated by the Netpbm tool 'makeman' from HTML |
| 187 |
source. The master documentation is at |
| 188 |
.IP |
| 189 |
.B http://netpbm.sourceforge.net/doc/pnmnlfilt.html |
| 190 |
.PP |