Adventurer #13
31 марта 2002

Exchange of experience - Floyd-Steinberg method for converting images from a larger number of colors in the least.

<b>Exchange of experience</b> - Floyd-Steinberg method for converting images from a larger
number of colors in the least.
    (C) Research / Volgasoft


         The method of Floyd-Steinberg


    Long time I was asked to enlighten our readers on account 
of the notorious method of FS. What kind of animal? - Ask some 
of you. An interesting animal. It is used when converting 
images from a larger the number of digits (colors) in the 
least. Example - 3Color, printer drivers (). And 
here and there the principle is the same. 


    In general, for dithering using 4 basic methods:


    1) the method of Floyd-Steinberg (, the result
Recalls Spectrum chunks (the same
matrix));

    3) method of comparing the intensity threshold (also all 
seen;)); 

    4) Method 3 with the admixture is uniformly
Distributed RND (still the same crap:).


    All methods, except for FS, you can think of
himself. In the method of Bayer certain complexity is the 
conclusion of the matrices, but stretched brains of the matrix 
is ​​still displayed, but FS unceremoniously not take it.



    Method - Mathematics. These bourgeois
it somehow brought this fact. He was a stray
in some book publishers <World> think, the 80-th. Knizhentsiya 
anything but entirely mathematics. Not school, not at all.

There have been filtering algorithms, and algorithms diterenga 
and cluzhila this, and yet a pair of clever books, as expected, 
I mean stand for the TV to work with Cache'a.



    In a nutshell, the principle of: modified
not only the current pixel, but also neighboring
- Left, bottom, and bottom-left of our
pixel along the diterenga. Here's an example
implementation of the method (of books):

 T = (white + black) / 2; threshold comparison

 for y = yMax to yMin step -1
 for x = xMin to xMax; array (X on Y)

 if i (x, y) <T; take a pixel
 then err = i (x, y)-black; i (x, y) = black
 else
 err = i (x, y)-white; i (x, y) = white
 plot (x, y);

 i (x +1, y) = i (x +1, y) +3 * err / 8
 i (x, y-1) = i (x, y-1) +3 * err / 8
 i (x +1, y-1) = i (x +1, y-1) +2 * err / 8
 next x
 next y


    Take the pixel, comparing with threshold
comparison. If the brightness is less than the threshold,
We set the screen black, consider the error equal to the pixel 
minus the black. 


    If the brightness above the threshold, then
We set the screen white, consider a mistake
equal to the pixel minus the white.


    And decompose the error in accordance
with a picture:


             +------+------+

             | | +3 / 8 |

             | Pixel | errors |

             | | |

             +------+------+

             | +3 / 8 | +2 / 8 |

             | Error | error |

             | | |

             +------+------+


    Well, go to the next pixel.
That's the whole method.


    Implementation Example - Free Art Demo -
4096 colors.


    Here is a piece of her to the annex.
Go tell that to implement the classic
FS can only be a decent accuracy of the calculations -16.0, and 
not 8.0 as in the example. 8.0 was preceded by a life a 
thousand and one fitting. Due to errors in calculations

(Fission) and overflows occur <hole "and" angles>. The doctor 
then made STS FS with an accuracy of 16.0 - feast for the eyes, 
but 16.0 eats more memory for the matrix and more

registers for calculations. How Dieterich -
left to right, right to left, top to bottom
etc. - Decide for yourself:


    In the example FS uses a single row of 256 bytes to store 
one line  and 2 rows of 256 bytes for diterenga (in the 
method is processed by only 2 rows). Voschem, there will not 
better See, it's easier to write your ;-))).



    Advantages of the method:


    1) Best quality;

    2) the absence of additional tables and
generators (unlike Bayer and laced RND) - hawala minuscule 
memory. 


    Disadvantages:


    1) a large amount of computation, and therefore - Ping;

    2) if diternut picture, and then in
it somewhere to put a pixel - to
Dieterich again, or at least supplied with the pixel to the end.


    That's right, here. What to do with it - already
Each came up with .. And I'm on this and say goodbye.


    P.S. that would paint the FS-ka translate it better in 
chunks, say MacroEdit 'om, which is released in a recent issue 
ADV. 






Other articles:

From the authors - help: a description of the shell magazine.

From the authors - the contents of the new magazine.

From the authors - Forever young, or the Spectrum in the new millennium. Call Jam / XPJ to save the log ZX Power.

From the authors - The authors of the magazine.

Presentation - new game from Studio Stall - opener.

Presentation - the new font editor Hewly Font Editor.

Presentation - A new version of the music editor of Sound Tracker Pro.

Presentation - a program for optimization of black and white images skonverchennyh with a PC.

Presentation - ASCII graphics editor for directories in the TR-DOS.

Presentation - "Bard's Tale Merger Programm" - a program to manage shipments of the game Bard's Tale.

Interface - News from: Placebo, Brain- wave, Phantom Family, Volga Soft, Studio Stall, Gogin, Anarchia, Image Crew, Hackerz 'Design Software, Peters +, Fatal Snipe, Ellipse.

Interface - see what tusni are scheduled for Speccy freaks vtechenie year: Forever 3, ASCII ^ 2002, 2nd International Sinclair Sam days, Millenium 1902, Twilight Demoparty 2002, Syndeecate Demoparty 2002, Paradox 2002, CaFe 2002, Chaos Constructions 2002.

Interface - a letter reading rooms: NoViSeT / Brutal Creators, Di / LSg, Moroz1999, Shame / Madness Technology, Cannibal / Techno Lab.

Interface - "for the market to answer!" Russian language is so "Great and powerful", that well use it, unfortunately, is given not for everyone.

Interface - Overview of Windows like shells and systems for ZX Spectrum.

Interface - City of Dzerzhinsk and its Spectrum inhabitants.

Exchange of experience - How to write a 3D game such as DOOM.

Exchange of experience - Floyd-Steinberg method for converting images from a larger number of colors in the least.

Exchange of experience - an unscientific Algorithm for Random Number (RND).

Exchange of experience - Direct Programming General Sound.

Exchange of experience - work with the western disk systems MDOS and MD02.

Chaos Construction 2001 - an interview with Raid.

Chaos Construction 2001 - an interview with Stanly / Studio Stall.

Chaos Construction 2001 - an interview with Gogin (Hacker Smir).

Chaos Construction 2001 - an interview with the Constellation Team: Screamer, Kot, Justinas.

Chaos Construction 2001 - Interview with EYE-Q: Organism, Time Keeper, Mr. Wizard.

Chaos Construction 2001 - an interview with Justionas / Constellation.

Chaos Construction 2001 - an interview with the Moscow encoder Asman / Proxium.

Chaos Construction 2001 - intevyu with Vivid, Megus, Tiggr of Brain-Wave.

Chaos Construction 2001 - an interview with Stingrey and Steep from Izhevsk.

Chaos Construction 2001 - an interview with amizhnikom and organizer CC - Big Black.

Chaos Construction 2001 - an interview with the encoder from Ulyanovsk Faster / TNL.

Chaos Construction 2001 - an interview with Cyberfreak (mooh).

Chaos Construction 2001 - an interview with Ming spektrumistom Equator / PHD.

Chaos Construction 2001 - mini interview with Kano.

Chaos Construction 2001 - an epic dispute: Vivid VS Sairoos, Chanks VS Multicolor, Dogma VS Triptomine Dream.

Chaos Construction 2001 - an interview with Maddy and Drv53b6 of the Phantom Family.

Chaos Construction 2001 - an interview with the Paracels and Sairoos of Placebo.

Chaos Construction 2001 - an interview with Pheel and EA from Antares.

Chaos Construction 2001 - continuation of the epic dispute between megakoderami Vivid and Sairoos.

Chaos Construction 2001 - a detailed report from the CPU.

Promotion - Another shattered dream or a description of the "500 games" - where truth and falsehood.

Promotion - the story creators of the game Star Glider 2 - Steven dunn / Software developement and design.

Promotion - Dizzy in a dungeon or omelette again did not turn out: short story for the game Dizzy Unterground.

Promotion - description of the game "Talisman" - RPG with elements of arcade.

Iron - the modified scheme IDE-HDD adapter.

Ottyag - clean ottyag: Children's self-made newspaper Bird Kar Kar. "

Ottyag - intro: We will not pull the cat by the balls and start with the run ...

Ottyag - Army Suxx or How zakosit from the army, if you are completely healthy.

Ottyag - the depth of a gloomy world outlook Maxima Magnet ...


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Our news - Full version of "Black Crow".
Party - CAFe 2002 report Arty Noonzen'a & Siril'a
News - news from other cities.

В этот день...   11 May