Basic Idea
Suppose there is an image I, and a blurred version of the image B.
I-B will give us the high frequency components of the image.
(By I - B i mean substracting the all the pixels of B from I.)
Now if we can amplify the high frequency components, the image will look sharp.
i.e., Sharpened image S = I + (I - B)
By giving a parameter k, we can adjust the amount of sharpness.
i.e., S = I + k*(I - B)
Finding Kernel
We can reduce it to a single kernel operation.
Then, I = Ii and B = Ib
Note: i is the kernel with central element 1, and all the rest with 0.
Then
S = I(i + k(i-b))
S = Is
Where s is the sharpening kernel
s = (i + k(i-b))
s = i + ki - kb
s = (k+1)i - k*b
So in practice:
- Read the dimensions of the blurring kernel b
- Create a sharpening kernel s of the same dimensions.
- Initialize every element of s to zero.
- For each element of s, subtract k times the corresponding element of b
- Add k+1 to the central element of s
Performance Note
with S = I + k*(I - B) is the most performant option.
Reference
https://blog.demofox.org/2022/02/26/image-sharpening-convolution-kernels/
