VB image processing, (4) Implementation of several common filters 2

Source: Internet
Author: User

Last time, we talked about the algorithm and implementation of sharpening, softening, spreading, and engraving filters.
See "VB image processing, (3) Implementation of several common filters 1"
In this article, I will share with you the pencil drawing algorithm and wood carving algorithm and their implementation.
Why should I put these two algorithms together? Because these two algorithms are very similar.
First, let's talk about the human eye's observation of images, and the human eye's sensitivity to gray (brightness ).
Human eyes are much more sensitive to warm and cold colors than to colors.
Sensitivity to General colors.
After a lot of tests, people have obtained an empirical formula to explain how the human eyes recognize brightness:
Gray = Red * 0.3 + Green * 0.6 + Blue * 0.1
The right side has a more similar formula because the human eyes are most sensitive to Green:
Gray = Green
Let's look back at how we did it when we used to see the landscape with pencil drawing eyes?
What is the outline, right? To put it bluntly, it is a gray-scale hop.
Therefore, we only need to set a threshold value to convert the color of the pixels in the images on the computer to the gray level.
When the gray scale of two adjacent pixels exceeds a certain amount, we determine that the gray scale is a contour.
Draw it out with a pencil.
With this idea, we can easily write this algorithm.
Public Sub penpencil (Optional ByVal sensiti.pdf As Long = 25)
Dim I As Long
Dim L As Long
Dim M As Long
Dim N As Long
Dim Col As Long
Dim ColNext As Long
'On Error GoTo ErrLine
If Not CanPut Then Exit Sub
Done = False
TimeFilter = timeGetTime
For I = 0 To OutPutWid-1
M = I + 1
For L = 0 To OutPutHei-1
N = L + 1
Col = ColOut (0, I, L) * 3 + ColOut (1, I, L) * 6 + ColOut (2, I, L)
Col = Col 10' the gray scale of the current vertex.
ColNext = ColOut (0, M, N) * 3 + ColOut (1, M, N) * 6 + ColOut (2, M, N)

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.