A 3x3 sharpening kernel (2D) looks like this:
0 -1 0
-1 5 -1
0 -1 0
Then what are the values of a 3x3x3 sharpening kernel (3D)?
CodePudding user response:
That sharpening kernel is formed by subtracting a smoothing kernel from the identity kernel. You can sharpen an image by subtracting (with appropriate weight) a blurred image, and then scaling the result so you don’t loose brightness. Not loosing brightness means that the kernel must sum to 1. In pseudo-math notation we have:
s1 I - s2 k * I = (s1 δ - s2 k) * I
with k
a smoothing kernel, δ
The identity kernel, I
an image, *
the convolution, and the other two variables appropriate scaling.
So a smoothing kernel could be
| 0 1 0 |
| 1 1 1 | / 5
| 0 1 0 |
The identity kernel is
| 0 0 0 |
| 0 1 0 |
| 0 0 0 |
And choosing s1=6
and s2=5
we get the following sharpening kernel:
| 0 -1 0 |
| -1 5 -1 |
| 0 -1 0 |
To build a 3D version we do exactly the same process, but with a 3D smoothing kernel. You could end up with two other -1 values, and the central pixel would get a value of 7.