1IM_SHARPEN(3)              Library Functions Manual              IM_SHARPEN(3)
2
3
4

NAME

6       im_sharpen - simple coring edge enhancement
7

SYNOPSIS

9       #include <vips/vips.h>
10
11       int
12       im_sharpen( in, out, mask_radius, x1, y2, y3, m1, m2 )
13       IMAGE *in, *out;
14       int mask_radius;
15       double x1, y2, y3;
16       double m1, m2;
17
18

DESCRIPTION

20       This  function  selectively  sharpens the L* channel of a LABPACK coded
21       image. It is suitable for preparing an image for printing, where  edges
22       need  to  be boosted to compensate for blurring introduced by the half-
23       tone process, and also for giving any additional `crispening' required.
24
25       The function operates as:
26
27         in    gaussian                                   out
28         --+-> blur with ----> subtract --> LUT --> add ---->
29           |   mask_radius        ^                  ^
30           |                      |                  |
31           +----------------------+                  |
32           |                                         |
33           +-----------------------------------------+
34
35       In other words, the L* channel is  smoothed  with  a  gaussian  average
36       function  of  radius  mask_radius and this smoothed image is subtracted
37       from the original L* to generate a high-frequency signal.
38
39       This high-frequency signal is passed through a look-up table  specified
40       by  the x1, y2, y3, m1 and m2 parameters and added back to the original
41       L* channel to generate the sharpened image.
42
43       The LUT is shaped as:
44
45                             ^
46                          y2 |- - - - - -----------
47                             |         /
48                             |        / slope m2
49                             |    .../
50                     -x1     | ...   |
51         -------------------...---------------------->
52                     |   ... |      x1
53                     |... slope m1
54                     /       |
55                    / m2     |
56                   /         |
57                  /          |
58                 /           |
59                /            |
60         ______/ _ _ _ _ _ _ | -y3
61                             |
62
63       When trying to understand the meaning of these parameters, it is  help‐
64       ful  to  imagine  a  cross-section through an image. Sharpening filters
65       boost apparent sharpness by performing  the  following  transformation.
66       Consider a cross-section through a soft edge:
67
68                             ^
69                             |          ..........
70                             |      ....
71                             |   ...
72                             | ..
73                             |.
74         --------------------+------------------->
75                            .|
76                          .. |
77                       ...   |
78                   ....      |
79         ..........          |
80                             |
81
82       This becomes an enhanced edge, perhaps:
83
84                             ^
85                             |   ...    overshoot
86                             |  .   .
87                             | .     ............
88                             | .
89                             |.
90                              .
91                             .
92         --------------------+------------------->
93                             .
94                            .|
95                            .|
96                           . |
97         .............     . |
98                      .   .  |
99           undershoot  ...   |
100                             |
101
102       There  are  two features: the transition from black to white has become
103       steeper, and there are positive  and  negative  undershoots  and  over‐
104       shoots.
105
106       As a general guide, some overshoot is good for printing (it helps exag‐
107       gerate the edge), but not too much, as you will  start  to  see  strong
108       white  fringes.   Undershoot  introduces  black  lines,  which are less
109       intrusive, so you can allow more under- than over-shoot.
110
111       im_sharpen uses the x1 parameter to distinguish between  low  and  high
112       frequency  areas.  Pixels  which  differ  by less than x1 L* units from
113       their local average are sharpened by factor 1+m1, and pixels which dif‐
114       fer  by more than x1 are sharpened by factor 1+m2. y2 and y3 set limits
115       on the amount of positive and negative sharpening we allow.
116
117       For printing, we recommend the following settings:
118
119          mask_radius == 7
120          x1 == 1.5
121          y2 == 20         (don't brighten by more than 20 L*)
122          y3 == 50         (can darken by up to 50 L*)
123
124          m1 == 1          (some sharpening in flat areas)
125          m2 == 2          (more sharpening in jaggy areas)
126
127       If you want more or less sharpening, we suggest you just change the  m1
128       and m2 parameters. For an extreme sharpen, you might try:
129
130          m1 == 2
131          m2 == 4
132
133       And for a relatively gentle sharpen, perhaps:
134
135          m1 == 0.5
136          m2 == 1.5
137
138       If you want to adjust the x1 parameter, it can be helpful visualise its
139       effect by setting:
140
141          m1 == -2
142          m2 == 4
143
144       In other words, heavily blur flat areas, and heavily sharpen elsewhere.
145       This  creates  a  terrible-looking  image,  but you will be able to see
146       clearly what parts of your image are being classified as flat.
147
148       The y2 and y3 parameters need not usually be adjusted, unless you  wish
149       to reduce the strength of the finges.
150
151       The  mask_radius  parameter  changes the width of the fringe and can be
152       adjusted according to the output printing resolution. As an approximate
153       guideline, use 3 for 4 pixels/mm (CRT display resolution), 5 for 8 pix‐
154       els/mm, 7 for 12 pixels/mm and 9 for 16 pixels/mm (300 dpi ==  12  pix‐
155       els/mm).  These  figures  refer  to the image raster, not the half-tone
156       resolution.
157
158

RETURN VALUE

160       The function returns 0 on success and -1 on error.
161

SEE ALSO

163       im_conv(3), im_compass(3), im_fastcor(3).
164
166       National Gallery and Birkbeck College, 1995
167

THANKS TO

169       Lindsay!
170
171
172
173                                  16 May 1995                    IM_SHARPEN(3)
Impressum