Paper 103: Lazy algorithm for color image high-speed blur

Source: Internet
Author: User

Engineering and source code: Fast blur. rar image Fuzzy Algorithm There are many kinds of, our most common is the mean fuzzy, that is, take a certain radius of the average value of the pixel values as the current point of the new pixel value, in general industrial applications often take 3*3 template, this small template in order to improve the speed, you can directly Expand the two-layer loop into an expression. But in the art of image processing, commonly used to a larger radius, then one to expand the calculation is not realistic, and to use the two-layer cycle will greatly reduce the speed, the three radius of the larger, the slower the calculation speed, therefore, must find a fast implementation of this effect of the algorithm, in the mean value of this relatively special case,         Using lazy algorithms may be a very effective and simple means of implementation. In the mean blur, in the process of calculating the results of a previous pixel, it involves the accumulation of r*r pixels around it, and in the process of calculating the next pixel, there will be (r-1) * (R-1) The surrounding points and the previous coincident (regardless of the edge point), so if we can properly utilize these coincident information,         In the process of calculation can effectively reduce the computational capacity, and this feature makes the fuzzy calculation of the relationship between the time and radius is basically insensitive.         Given the circumstances of the edge pixels, our calculations can be divided into three stages.     The first step: Calculate the result value of the pixel in the top left corner of the image, and record the sum of each color component and the effective pixels. For X = 0 to rad ' Loop does not need to be from-rad to Rad, because we know clearly no data at-rad to 0 images
For y = 0 to Rad calculates the blur value of the first pixel in the upper-left corner, recording the color components and the effective pixels
PDATAARRC (0) = mptrc + mwidthbytes * y + X * 4 ' point to the number of sentences we need in the backup data address (first address + height * Scan line width + width * bytes per pixel)
sumred (0) = sumred (0) + DATAARRC (2) ' accumulated value
Sumgreen (0) = Sumgreen (0) + DATAARRC (1)
Sumblue (0) = Sumblue (0) + DATAARRC (0)
Sumnum (0) = Sumnum (0) + 1 ' counter plus one
Next
Next Step two: Calculate the blur value of the first row of pixels in addition to the other pixels in the 0,0 point, which takes full advantage of the first step of the information.       The code for this step is detailed in the project.       In the third step, based on the first line of the image, the fuzzy values of the following lines are calculated at once, there are some actions to move the information out and move in, and there are some things to be aware of in the edge operation.       Note that in my project, the starting point of the image data is fixed to the upper left corner of the screen, and this is done in order to unify the GDI coordinate system, which in many cases will bring convenience. In Gaussian blur, we can also use a similar method to optimize the algorithm, this can refer to the Paint.NET code.

Paper 103: Lazy algorithm for color image high-speed blur

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.