[] Error diffusion image processing algorithm (jitter) of the image processing algorithm

          [] Error diffusion image processing algorithm (jitter) of the image processing algorithm

I. Introduction to Algorithms

Expansion often encountered error spread method in the data processing, in particular for image processing, reducing the color depth. FIG three below, [a] in FIG. 256 (8bit) two gradation over [FIG] FIG 16 is converted into a (8bit) gradations (4 bits unchanged high, 0 low position 4)] to three [FIG. FIG 16 is converted into a gradation by the error diffusion method. (256 refers to the total gray value of 256 gradations, 16 refers to the gray value of 16 gray scales)

801 bytes         646 bytes           2539 bytes

[FIG] [a] [Figure III Figure II]

Obviously, the same 16-level gray scale, but [Figure III] significantly better than the [two] FIG. The reason is [two] FIG spread using spread error algorithm.

As the name implies, spread error diffuser, the color depth is reduced when the error variation to the pixel expansion cast, so that the naked eye when viewed image, adjacent pixels of the entire set of error small, it is for example: when the person next staircase If the step is too high, easily pulled egg; if the same height can be more than a few steps, then the distance between the step is small, then the effect will be reduced or even disappear Chedan (sorry, I call Chedan effect).

Second, the specific process

1, if we want this one 256-level grayscale image converted to a 16-level grayscale, the easiest way is to post four each pixel position 0. E.g. 256 gray values ​​are 120, converted gradation value is 16 are: 120/16 * 16 = 112 = 7.5,7, i.e. 16 gray value 112, then there is 120-112 = 8 (i.e., 0.5 * 16 = 8) of pixel difference, which is an error. If you do not use this error information, it is the effect of the [two] FIG.

16 256 gray gray conversion method: i.e., to 256 levels of gray were divided into 16 aliquots, conversion time, only 256 gray levels which is determined in a range of 16 aliquots, and the section with the smallest grayscale value as 16 shades of gray. which is:

if((x>0) && (x<=16))
	Grayscale_value = 0=16;
else if((x > 16)&&( x<=32))
	Grayscale_value = 32;
else if((x > 32)&&( x<=48))
	Grayscale_value = 48;
else if((x > 48)&&( x<=64))
	Grayscale_value = 64;
else if((x > 64)&&( x<=80))
	Grayscale_value = 80;
else if((x > 80)&&( x<=96))
	Grayscale_value = 96;
else if((x > 96)&&( x<=112))
	Grayscale_value = 112;
else if((x > 112)&&( x<=128))
	Grayscale_value = 128;
else if((x > 128)&&( x<=144))
	Grayscale_value = 144;
else if((x > 144)&&( x<=160))
	Grayscale_value = 160;
else if((x > 160)&&( x<=176))
	Grayscale_value = 176;
else if((x > 176)&&( x<=182))
	Grayscale_value = 182;
else if((x > 182)&&( x<=198))
	Grayscale_value = 198;
else if((x > 198)&&( x<=214))
	Grayscale_value = 214;
else if((x > 214)&&( x<=230))
	Grayscale_value = 230;
else if((x > 230)&&( x<=246))
	Grayscale_value = 246;
else if((x > 246))
	Grayscale_value = 255;

It may be directly calculated according to the equation as the author intended.
2, error diffusion (jitter), [Figure II] in order to solve the phenomenon, we have to take advantage of this error, the error is about to spread to the periphery of the pixel, rather than fully bear the errors caused by the pixel. In this way from the visual point of view, it will be more gentle, more receptive. We follow the 3: 2: 3 ratio of 8 to the right of the batch error pixel, lower right, lower side of these surrounding pixels, i.e., pixels to the right of the right pixel = + 3, the lower right pixel = lower right pixel + 2, below the lower pixel pixel = +3, this way, processes each pixel of the whole picture is not much better than the direct effect of censoring it?

In the above description, this particular bit error in example 8, the error is 13, press 3: 2: 3 to obtain the error allocation 2,1,2 (or 3,2,3 rounded).

In fact, the 3: 2: 3 The effect is not the best allocation errors bill, you can also try the following points system (you can also construct your own):

 

Wherein X denotes the pixel to be converted, the proportion of error around divide.

ok, this algorithm is quite useful, due to the relatively simple, do not give the code, you can realize your own look.
----------------
Disclaimer: This article is CSDN blogger "hujingshuang 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/hujingshuang/article/details/45716445

Published 49 original articles · won praise 138 · Views 300,000 +

Guess you like

Origin blog.csdn.net/lz0499/article/details/101623126