Error diffusion (jitter) algorithm for image processing

Source: Internet
Author: User

Preface: This article was originally published in Sina blog http://blog.sina.com.cn/s/blog_b27f71160101ggzd.html, is now Sina blog to move to Csdn, the original Sina blog stopped updating.

① after applying for move, delay to receive the code to move

② a little bit more familiar with the algorithm

③ Contact Keyboard Typing

Based on the three points above, the blog post is knocked over again.

First, the algorithm introduction

The method of error spreading is often encountered in data processing, especially in image processing, which reduces the depth of color. Below are three pictures, "figure one" 256-level (8bit) gray-scale over "figure two" will be converted to 16-level (8bit) grayscale (high 4-bit unchanged, low 4-bit 0) "Figure three" graph one using the error diffusion method to convert to 16-level grayscale. (256 levels of gray refers to a total of 256 gray values, 16-level gray refers to a total of 16 gray values)


"Figure I" "Figure two" "Figure three"

Obviously, the same is 16 levels of gray, but the effect of "figure three" is significantly better than "Figure II", the reason is that "figure II" using the error spread algorithm.

As the name implies, the error spread, that is, when the color depth is reduced, the error of the pixel changes to expand Sakai, so that the naked eye in the observation of the picture, the adjacent pixel set the overall error becomes smaller, such as: When the stairs, if the stair is too high, easy to pull the egg; Then the distance between the steps becomes smaller, and the effect of the egg-pulling will decrease or even disappear (I'm sorry, I call it the pull-egg effect).

Ii. specific process

1, if we want to convert this 256-level grayscale image into 16 levels of grayscale, the simplest way is to put the last four positions of each pixel 0. For example, the level 256 grayscale value is 120, converted to 16 levels of gray values are: 120/16=7.5,7*16=112, that is, 16 levels of gray value is 112, there is 120-112=8 (that is, 0.5*16=8) pixel difference, this is the error. If you do not use this error information, it is the effect of "figure II".


2, Error diffusion (jitter), in order to solve the "figure II" phenomenon, we have to take advantage of this error, the error will be spread to the pixel around the point, rather than by the pixel completely bear the error. From a visual perspective, it will be more gradual and easier to accept. We will 8 this error in proportion to the right side of the pixel, lower right, the bottom of these surrounding pixels, that is, the right pixel = right pixel +3, the lower right pixel = right pixel +2, the bottom pixel = the lower pixel +3, so that the entire image of the pixel, so that the process of processing all the pixels, the whole picture, Is it much better than the effect of direct truncation?

In the above note, the example of this error 8 is a bit special, the error is 13, then the error assigned by 3:2:3 is 2,1,2 (or rounded 3,2,3).

In fact, the effect of 3:2:3 is not the best allocation Error Act, you can also try the following sub-method (you can also construct yourself):


where x refers to the proportion of pixels that are to be converted to the dividing error around the pixel point.

OK, this algorithm is still more useful, because it is relatively simple, do not give the code, you can implement it yourself.



Error diffusion (jitter) algorithm for image processing

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.