version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
pnmnlfilt |
|
|
2 |
!!!pnmnlfilt |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
Alpha trimmed mean filter. (0.0 |
|
|
7 |
Optimal estimation smoothing. (1.0 |
|
|
8 |
Edge enhancement. (-0.1 |
|
|
9 |
Combination use. |
|
|
10 |
References: |
|
|
11 |
SEE ALSO |
|
|
12 |
BUGS |
|
|
13 |
AUTHOR |
|
|
14 |
---- |
|
|
15 |
!!NAME |
|
|
16 |
|
|
|
17 |
|
|
|
18 |
pnmnlfilt - non-linear filters: smooth, alpha trim mean, optimal estimation smoothing, edge enhancement. |
|
|
19 |
!!SYNOPSIS |
|
|
20 |
|
|
|
21 |
|
|
|
22 |
__pnmnlfilt__ alpha radius [[''pnmfile''] |
|
|
23 |
!!DESCRIPTION |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
This is something of a swiss army knife filter. It has 3 |
|
|
27 |
distinct operating modes. In all of the modes each pixel in |
|
|
28 |
the image is examined and processed according to it and its |
|
|
29 |
surrounding pixels values. Rather than using the 9 pixels in |
|
|
30 |
a 3x3 block, 7 hexagonal area samples are taken, the size of |
|
|
31 |
the hexagons being controlled by the radius parameter. A |
|
|
32 |
radius value of 0.3333 means that the 7 hexagons exactly fit |
|
|
33 |
into the center pixel (ie. there will be no filtering |
|
|
34 |
effect). A radius value of 1.0 means that the 7 hexagons |
|
|
35 |
exactly fit a 3x3 pixel array. |
|
|
36 |
!!Alpha trimmed mean filter. (0.0 !! |
|
|
37 |
|
|
|
38 |
|
|
|
39 |
The value of the center pixel will be replaced by the mean |
|
|
40 |
of the 7 hexagon values, but the 7 values are sorted by size |
|
|
41 |
and the top and bottom alpha portion of the 7 are excluded |
|
|
42 |
from the mean. This implies that an alpha value of 0.0 gives |
|
|
43 |
the same sort of output as a normal convolution (ie. |
|
|
44 |
averaging or smoothing filter), where radius will determine |
|
|
45 |
the |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
An alpha value of 0.5 will cause the median value of the 7 |
|
|
49 |
hexagons to be used to replace the center pixel value. This |
|
|
50 |
sort of filter is good for eliminating |
|
|
51 |
!!Optimal estimation smoothing. (1.0 !! |
|
|
52 |
|
|
|
53 |
|
|
|
54 |
This type of filter applies a smoothing filter adaptively |
|
|
55 |
over the image. For each pixel the variance of the |
|
|
56 |
surrounding hexagon values is calculated, and the amount of |
|
|
57 |
smoothing is made inversely proportional to it. The idea is |
|
|
58 |
that if the variance is small then it is due to noise in the |
|
|
59 |
image, while if the variance is large, it is because of |
|
|
60 |
!!Edge enhancement. (-0.1 !! |
|
|
61 |
|
|
|
62 |
|
|
|
63 |
This is the opposite type of filter to the smoothing filter. |
|
|
64 |
It enhances edges. The alpha parameter controls the amount |
|
|
65 |
of edge enhancement, from subtle (-0.1) to blatant (-0.9). |
|
|
66 |
The radius parameter controls the effective radius as usual, |
|
|
67 |
but useful values are between 0.5 and 0.9. Try starting with |
|
|
68 |
values of alpha = 0.3, radius = 0.8 |
|
|
69 |
!!Combination use. |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
The various modes of __pnmnlfilt__ can be used one after |
|
|
73 |
the other to get the desired result. For instance to turn a |
|
|
74 |
monochrome dithered image into a grayscale image you could |
|
|
75 |
try one or two passes of the smoothing filter, followed by a |
|
|
76 |
pass of the optimal estimation filter, then some subtle edge |
|
|
77 |
enhancement. Note that using edge enhancement is only likely |
|
|
78 |
to be useful after one of the non-linear filters (alpha |
|
|
79 |
trimmed mean or optimal estimation filter), as edge |
|
|
80 |
enhancement is the direct opposite of |
|
|
81 |
smoothing. |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
For reducing color quantization noise in images (ie. turning |
|
|
85 |
.gif files back into 24 bit files) you could try a pass of |
|
|
86 |
the optimal estimation filter (alpha 1.2, radius 1.0), a |
|
|
87 |
pass of the median filter (alpha 0.5, radius 0.55), and |
|
|
88 |
possibly a pass of the edge enhancement filter. Several |
|
|
89 |
passes of the optimal estimation filter with declining alpha |
|
|
90 |
values are more effective than a single pass with a large |
|
|
91 |
alpha value. As usual, there is a tradeoff between filtering |
|
|
92 |
effectiveness and loosing detail. Experimentation is |
|
|
93 |
encouraged. |
|
|
94 |
!!References: |
|
|
95 |
|
|
|
96 |
|
|
|
97 |
The alpha-trimmed mean filter is based on the description in |
|
|
98 |
IEEE CG |
|
|
99 |
|
|
|
100 |
|
|
|
101 |
The optimal estimation filter is taken from an article |
|
|
102 |
|
|
|
103 |
|
|
|
104 |
The edge enhancement details are from pgmenhance(1), which |
|
|
105 |
is taken from Philip R. Thompson's |
|
|
106 |
!!SEE ALSO |
|
|
107 |
|
|
|
108 |
|
|
|
109 |
pgmenhance(1), pnmconvol(1), pnm(5) |
|
|
110 |
!!BUGS |
|
|
111 |
|
|
|
112 |
|
|
|
113 |
Integers and tables may overflow if PPM_MAXMAXVAL is greater |
|
|
114 |
than 255. |
|
|
115 |
!!AUTHOR |
|
|
116 |
|
|
|
117 |
|
|
|
118 |
Graeme W. Gill graeme@labtam.oz.au |
|
|
119 |
---- |