VB image processing, (3) Implementation of several common filters 1

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.