Photoshop_User_February_2017

(Nancy Kaufman) #1
HOW TO ››

› ›

photoshop user

› february 2017

060


THE KERNEL
Sharpening a digital image requires math, and the kind
of math it usually requires involves matrices. A matrix is
just a two-dimensional array of related values. This is really
useful to digital images because they’re arrays of pixel
values—brightness and color, right? So we’re going to
look at a particular kind of matrix math called a kernel. A
kernel takes a given pixel and replaces its value with a new,
calculated value.
Think of a kernel like a mask that tells you what to do
with each pixel in an image, based on that pixel’s neigh-
bors. The kernel is centered on the pixel value that will be
replaced, and the other numbers around the center of the
kernel are multipliers for the values of the neighbor pixels in
those locations. So if I want to adjust a specific pixel using a
3x3 kernel (nine total pixels), I’d place the mask (kernel) on
that pixel (147 in this example), take the values of the eight
pixels around it and multiply by the corresponding values in
the kernel (the values for the kernel are shown in the image
below). The results are then added up. That’s my new spe-
cific pixel’s value. So in this example, starting in the top row,
you’d multiply 200 and 0, 187 and –1, and 169 and 0, etc.
You’d then end up with a total of nine values that you’d add
together for a sum of 136, which becomes the new value of
the center pixel in the 3x3 grid of pixels.

The kernel is then moved over by one pixel and the pro-
cess repeats using the original value in that location. All of
the original pixels are given the same treatment individually,
so you don’t end up using the output of the previous cal-
culation as the input to the next. If a square in the kernel
has no value, the pixel corresponding to that square doesn’t
contribute to the average new value. Also note that if all the
starting pixels within the kernel’s radius are the same, there
should be no change at all.
Basic sharpening uses the kernel shown below, and it
increases contrast by pushing bright pixels brighter, and dark
pixels darker based on their neighbors! So you don’t have
to know “how much” because it’s built in. Cool, huh? The
kernel doesn’t inherently “know” what an edge is, only that
there are differences between pixels. When you run the ker-
nel over an entire image, you begin to impose a pattern of
changes that results in a sharper image. A kernel has no real
use on a single pixel; it’s only when the kernel is applied to a
region of an image that it really makes sense.
So the answer to “how much” really is this: it’s rela-
tive. You’ll know when you see a boundary or edge in an
image, and you’ll determine for yourself if it’s soft or sharp.
If that sounds like a bit of a cheat, it is. It’s really not mean-
ingful to have a precise definition of “edge” beyond what

MATRIX KERNEL RESULT
Free download pdf