We have discussed the application of quadratic linear interpolation.
This article describes how to sharpen, soften, spread, and engrave filters.
1. Sharpen
The sharpening algorithm is very simple, that is, to compare several adjacent pixels. You can add the difference between the current pixel and the surrounding pixel.
Here is an example:
A B C D
E F G H
I J K L
M N O P
Suppose there is an image, 4*4, a total of 16 pixels, represented by A--L respectively.
First, let's look at this picture. Only the "neighbors" of the Four pixels F, G, J, and K in the middle are complete.
For simplicity, we only process these four pixels, because the actual image size is composed of many pixels, therefore, the final effect will not be affected if a circle of pixels is not processed.
Calculate the difference value first: Delta = F-(A + B + C + E + G + I + J + K)/8
(A + B + C + E + G + I + J + K)/8 is the average value of pixels around F,
Multiply the average value by a coefficient and then add it to F. A new F value is obtained:
F = F + Delta * Alpha
This Alpha coefficient is the sharpness degree. changing this coefficient will produce different sharpening effects. However, it is usually relatively small, such as: 0.3
Therefore, we only need to use two cycles to traverse the entire image's pixel value (remove the border) to achieve a sharpening effect.
However, you may find that the value of the preceding vertex is no longer the original value when processing the following vertices,
For example, when processing G, the value of F needs to be used, while the value of F has been changed, and the change of F is related to the value of G, which will become a type of circular reference. To avoid the entire problem, here is an improved method:
A B C D
E F G H
I J K L
M N O P
We started from point A and changed the difference calculation method:
Delta = A-(B + E + F)/3
F = F + Delta * Alpha
Scan all pixels in the order from left to right, from top to bottom. In this case, no processed pixels will be encountered during calculation, and the pixels involved in calculation are reduced, the entire process is also accelerated.
According to the pixel array we have obtained in VB Image Processing (1) pixel acquisition and output. We can write as follows:
Public Sub Sharp (Optional ByVal SharpDgree As Single = 0.3)