Blurring and Sharpening
Blurring convolves an image with a smoothing kernel whose weights are nonnegative and sum to . A blur is a low-pass filter: it keeps slow brightness changes (low spatial frequencies) and weakens fast ones. The two standard blur kernels are the box filter and the Gaussian . The box averages a square window with equal weights, and the Gaussian’s weights fall off with distance from the center. Their Fourier transforms explain how they differ. For a 1D box of width and height , and for a Gaussian of standard deviation , the transforms are
Here is the angular frequency in radians per pixel. The box’s transform is a sinc. It has zeros, negative lobes and slowly decaying ripples, so a box blur keeps some high frequencies and flips the sign of others. These show up as blocky, “edgy” artifacts. The Gaussian’s transform is another Gaussian, which is positive and decreasing, so a Gaussian blur removes high frequencies smoothly and without ringing.Subtracting the blur from the image leaves the details, a high-pass image , where is the unit impulse. Sharpening adds extra detail back with a strength . The unsharp mask filter is
The last form is a single convolution with the kernel , which sums to . Setting returns . Larger sharpens more, and very large produces halos and amplified noise. The kernel is a spike with a negative surround, which the lecture calls a Laplacian of Gaussian. Sharpening cannot restore detail that a blur has removed, so blurring a photo and then sharpening it does not return the original.
Sign of the Laplacian of Gaussian
The slide writes “unit impulse minus Gaussian Laplacian of Gaussian”. The Laplacian is negative at the center and positive in a ring around it. The kernel is positive at the center and negative around it. So approximates the shape of , up to a scale factor. Flipping the sign of a kernel flips the sign of its output, and it passes the same band of frequencies.
Intuition
A blur replaces each pixel with a local average. Averaging cancels random noise and fine texture, and it keeps large shapes. An image therefore splits into two parts: a smooth part and the details that the blur removed. A photo looks sharper when its details are stronger, so sharpening adds a multiple of the details back. The name comes from film photography. A blurred, or “unsharp”, positive copy of a negative was sandwiched with the negative as a mask. The mask cancelled part of the coarse contrast, so fine edges stood out in the print. The digital filter performs the same subtraction with arithmetic.
The shape of the blur kernel matters as much as its size. A box filter gives every neighbor the same weight and then drops to zero at a hard border. In the frequency domain that hard border becomes a sinc with ripples, and the ripples let some fine patterns through with their contrast inverted. A Gaussian has no hard border, and its transform has no ripples. The diagram compares a box and a Gaussian of equal variance in both domains.
\usepackage{tikz}
\begin{document}
\definecolor{box}{HTML}{D9483B}
\definecolor{gau}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\begin{tikzpicture}[x=1cm,y=2cm,>=latex,font=\small]
% spatial domain
\draw[->,mid] (-2.6,0) -- (2.8,0) node[right] {$x$};
\draw[->,mid] (0,-0.1) -- (0,1.25);
\draw[very thick,box] (-2.5,0) -- (-1,0) -- (-1,0.5) -- (1,0.5) -- (1,0) -- (2.5,0);
\draw[very thick,gau,domain=-2.5:2.5,samples=100] plot (\x,{0.69*exp(-\x*\x/(2*0.577*0.577))});
\node[box] at (1.5,0.62) {box};
\node[gau] at (1.0,1.0) {Gaussian};
\node[above] at (0,1.3) {spatial domain (kernel)};
% frequency domain
\begin{scope}[xshift=7cm]
\draw[->,mid] (-3.2,0) -- (3.4,0) node[right] {$\omega$};
\draw[->,mid] (0,-0.4) -- (0,1.25);
\draw[very thick,box,domain=-3.1:3.1,samples=300] plot (\x,{sin(3*\x r)/(3*\x+0.00001)});
\draw[very thick,gau,domain=-3.1:3.1,samples=150] plot (\x,{exp(-0.577*0.577*9*\x*\x/2)});
\node[box,right] at (1.25,-0.32) {sinc: negative lobes};
\node[gau,right] at (0.75,0.75) {Gaussian};
\draw[mid] (-0.08,1) -- (0.08,1) node[left=3pt] {$1$};
\node[above] at (0,1.3) {frequency domain (gain $\hat{H}(\omega)$)};
\end{scope}
\end{tikzpicture}
\end{document}Properties
(Reading the Sinc) A box of width deletes patterns whose period is and inverts the contrast of patterns with periods in between.
The sinc is zero at for , which are the patterns with periods pixels. Between the first two zeros the gain is negative. Its most negative value is , reached at a period of about . A stripe pattern with that period comes out at of its contrast, with light and dark swapped. The ripples decay only like , so a box blur never fully removes fine texture. A Gaussian’s gain is positive at every frequency, so it never swaps light and dark. The box’s blocky look in the slide comparison comes from these surviving, partly inverted high frequencies.
(Unit Sum) A kernel’s gain at zero frequency is the sum of its weights, so blur and unsharp mask both preserve mean brightness.
The frequency response at is . Every blur kernel and every unsharp kernel sums to , so flat regions and the image mean are unchanged. The detail kernel sums to , so the detail image has mean near and contains negative values. To display it, add a constant such as on a scale or rescale it to the full range. Displaying it without an offset clips every negative value to black.
(Halos and Overflow) Sharpening overshoots on both sides of an edge, and the overshoot grows with .
The diagram shows a step from to sharpened with and . The dark side dips to and the bright side rises to . These bands are the halos visible around edges in oversharpened photos. With the values reach and . The lies below the valid range, so the result must be clipped, and a slightly brighter edge would push the overshoot above too. In NumPy, arithmetic on uint8 arrays wraps around (for example ), so convert to float before filtering and clip to or at the end.
\usepackage{tikz}
\begin{document}
\definecolor{orig}{HTML}{8A8A8A}
\definecolor{blur}{HTML}{2F80ED}
\definecolor{sharp}{HTML}{D9483B}
\begin{tikzpicture}[x=0.9cm,y=0.025cm,>=latex,font=\small]
\draw[->,orig] (-0.5,0) -- (8.6,0) node[right] {pixel $i$};
\draw[->,orig] (-0.5,-10) -- (-0.5,200) node[above] {intensity};
\foreach \v in {50,100,150} \draw[orig] (-0.6,\v) -- (-0.4,\v) node[left=2pt] {\v};
\draw[thick,orig] (0,50) -- (3.5,50) -- (3.5,150) -- (8,150);
\draw[thick,blur] (0,50) -- (2,50) -- (3,75) -- (4,125) -- (5,150) -- (8,150);
\draw[very thick,sharp] (0,50) -- (2,50) -- (3,25) -- (4,175) -- (5,150) -- (8,150);
\foreach \x/\y in {0/50,1/50,2/50,3/25,4/175,5/150,6/150,7/150,8/150} \fill[sharp] (\x,\y) circle (2.2pt);
\node[orig,right] at (5.2,138) {original $f$};
\node[blur,right] at (4.2,110) {blurred $f * g$};
\node[sharp,right] at (4.2,182) {sharpened, $\alpha = 1$};
\node[sharp,left] at (2.9,18) {undershoot};
\end{tikzpicture}
\end{document}(Frequency Response of Sharpening) The unsharp mask multiplies each frequency by .
This gain is at and rises toward at high frequencies. The blur’s sets where the rise happens. A small boosts only the finest texture, together with pixel noise. A larger boosts contrast at a coarser scale, which looks like stronger local contrast. Sensor noise sits mostly at high frequencies, so sharpening a noisy photo amplifies its noise by up to a factor of .
(Sharpening Is Not Deblurring) Blurring and then sharpening multiplies each frequency by , which stays below where the blur was strong.
Undoing a blur exactly would need a gain of at every frequency. That gain is enormous wherever is near , and it would multiply the noise there by the same amount. The unsharp mask’s gain never exceeds , so it restores middle frequencies and leaves the finest ones lost. A blurred-then-sharpened photo has stronger edges than the blurred one but less fine texture than the original.
(Blurring Twice) Two Gaussian blurs in a row equal one Gaussian blur with .
The transfer functions multiply: . Variances add, as for sums of independent Gaussian random variables. Applying the same blur times gives an effective , not . This matters when building a Gaussian stack level by level, as in 2.5. Image Pyramids. Repeated box blurs approach a Gaussian shape, for the same central-limit reason.
Examples
(Easy) Sharpening a Step Edge
A row of a photo steps from to : . The blur is and the sharpening strength is .
Build the single unsharp kernel, apply it in valid mode, and repeat for and . The kernel is , which sums to . Valid mode gives outputs: . The two-step route gives the same values. The blur is at those positions, the details are , and plus the details matches. Flat regions are untouched, and the edge gains an undershoot to and an overshoot to .
With the kernel is and the edge pixels become and . With the kernel is and they become and . An 8-bit image must clip the to , and the clipped dark band shows as a black outline.
(Medium) Fine Stripes Through a Box and a Gaussian
A brick wall photographed from a distance shows stripes with a period of pixels, modeled as . It is blurred with a 5-tap box filter, and separately with a Gaussian of the same variance.
What comes out of each blur? What happens to stripes with a period of pixels? The 5-tap box has frequency response . At this is . The output is . The stripes keep of their contrast, and bright and dark rows swap. Period-5 stripes sit exactly on a zero of the response and vanish.
The box weights at offsets have variance , so the matching Gaussian has . Its gain at is . The Gaussian removes the stripes almost completely, and it never inverts them. This is the box’s “edgy” artifact in numbers.
(Hard) Blur a Sharp Photo, Then Sharpen It
A sharp photo is blurred with a Gaussian of pixels (half-width ). The result is then sharpened with an unsharp mask that uses the same Gaussian.
For patterns with periods of , and pixels, find the blur's gain and the combined gain with and . What would restore each pattern? The discrete Gaussian's gains are about at period , at period , and at period . The combined gain is . At period it is for and for . At period it is for and for . Setting the combined gain to gives . That is about for period , for period , and for period . A strength of would amplify noise more than a hundredfold. The sharpened photo regains its medium-scale edges, but its finest texture stays lost.
See Also
- 2.1.1. Linear Filters, for kernel construction, separability and boundary handling.
- 2.7. Hybrid Images, which combines a low-pass of one image with a high-pass of another.
- 2.4. Anti-Aliasing, which blurs before downsampling for the same frequency reasons.
- 2.2d LTI Frequency Response, the 1D signals view of a filter’s gain at each frequency.