Demo or Die #01
28 февраля 1999

Demo-Building - filtration pastpovyh izobpazheny. An algorithm to postpoeniya bugpyvistyh of surfaces. Flame effect. blurring in fast movement. Sharpening

<b>Demo-Building</b> - filtration pastpovyh izobpazheny. An algorithm to postpoeniya bugpyvistyh
of surfaces. Flame effect. blurring in fast
movement. Sharpening
__________________________________________

(C) by Wolf of eTc group / Scene


      Local filtering of raster

               images.


   Local Filtering - a technique
RIP,
will improve its quality:
reduce distortions, increase sharpness,
Select the path, etc. It should be noted
that filtering is also implemented, such
effects of the fire (which has become very
fashion because of its simplicity, and all have
tired), creation of textures (in the form
bugryvistoy surface) and motion blur
(Blurred images during fast
motion). Speccy at the local filtering
used mainly for "chankovskih or
attribute effects.

   The method is to move
on local image window (the matrix).
Window passes over the image so that
each pixel once it is centered.
On the window is defined weighty function H (p, q),
where p, q - the coordinates of the center pixel
window. This weighty function defines a new
color pixel, which is the center of the window.
Filtering effect depends only on
function H. The window size is usually 3x3,
5x5 or 7x7, etc.


   Such as the window for smoothing
image is the following:


                    0 1 0

     A [i, j] = 1 / 8 * 1 4 1

                    0 1 0


   D = 1 / 8 - factor


   C '[x, y] = D * Sum A [i, j] * C [i, j]

                 i, j


   matrix C [n, m] - an array of any
image.

   (I, j - integer. For example, from -1 to 1)


   If the pixel values ​​are taken from
the initial image, and the new values
after applying the filtering are stored in
new image (in a sort of buffer), then
This filter is called simple. If
new values ​​are recorded in the same
buffer where there was an initial image
and thus affects the further
filtering, called recursive.

   When you filter an image can
arise unpleasant effect when the window
located on the edge of the image, and thus
part of it goes beyond the buffer.
There are 3 basic processing circuitry edges
image.


   P-scheme is to move the window
the image so that-be not one of his
element has never been beyond
image. Ie, some pixels
located on the edge of the image is simply not
processed.


   S-scheme allows the exit window outside the
Images and programmed so that
the process of calculating the weighting function
window elements, which do not correspond to
real pixels, just do not participate.


   T-scheme considers the image so
that when a window (hereinafter referred to him will I
call filter) abroad
images, such as left, it
superimposed on the extreme pixels
image on the right with a shift down
one pixel.


   Thus, we consider several algorithms
using linear filters.


   1. Algorithm for constructing bugryvistyh
surfaces.


   This algorithm is often used to
creating textures or background for any
any effect.

   First of all we need to define
What will we have the size of a two-dimensional
buffer to create texture. Let it
will be an array Texture [m, n], where m and n -
width and height of the texture.

   For something to create bugryvistuyu
surface in the array to fill
its random numbers. Only
the maximum random number must
correspond to the maximum value
the level of a color (gradation).
For example, if it would be "chankovskaya"
texture, it is known, it has 16
brightness levels. Then we will array
(Buffer) to fill in as follows:


               LD HL, BUFFER

               ; Buffer address

               LD BC, N * M

               , Array size
FILL_RND: CALL RANDOM

               ; Random number generator

               ; A = random number (Max = 16)

               LD (HL), A

               INC HL

               DEC BC

               LD A, B

               OR C

               JR NZ, FILL_RND


   Now fill the buffer with random
numbers, write a procedure for filtering
smoothing the image.


        Filter we have is as follows:


                    1 1 1

              1 / 9 * 1 1 1

                    1 1 1


   Given that this filter all
value 1 over is not necessary to multiply the value
buffer on the filter (I think all
it is clear that multiplying by one number does not
change:) Then we need only
add and divide by 9, although
principle it is possible and 8 (total shift
number in 3 digits to the right) but the texture
will be less correct than 9.
For understanding and clarity, I will
Register to apply IX, but you never (!!!!)
in their effects do not abuse them.
Although decrunching'a and so will come down:)

FILTER:

               LD A, (IX)

               LD B, (IX +1)

               ADD A, B

               LD B, (IX-1)

               ADD A, B

               LD B, (IX-M)

               ADD A, B

               LD B, (IX + M)

               ADD A, B

               LD B, (IX + M +1)

               ADD A, B

               LD B, (IX + M-1)

               ADD A, B

               LD B, (IX-M +1)

               ADD A, B

               LD B, (IX-M-1)

               ADD A, B

               CALL A / 9; procedure division

               LD (IX), A

               RET



   Well and, accordingly, filtration cycle:

FILT:

               LD IX, BUFFER + M +1

               ; Edge filter will not

               LD B, N-2 height
FILL_N: PUSH BC

               PUSH IX

               LD B, M-2
FILL_M: CALL FILTER

               DJNZ FILL_M

               POP IX

               ADD IX, M

               POP BC

               DJNZ FILL_N



   For that, there were not boundary
effects, the easiest way is
Texture Filtering, which is the size
will be a little more necessary and then
can only "cut" satisfying
part.



   2. The effect of the flame (Flame).


   I understand that this effect is already well
tired, but not all are so smart as you and
know how it is implemented:)

   Does this effect is elementary,
install an array whose size
depends on the screen. Then performs
the following steps:


   1. Fill the last row of the array
random numbers. Where the maximum number of
should correspond to the maximum
the level of any color.

   2. Profiltruem this array, as
done above (procedure FILT).

   3. Move the image in an array on
unit up. It's up to the flames
moved.


   And it's all cyclically repeated.


   3. Sharpening


   Filter for sharpening:


                     0 -1 0

              A = -1 5 -1

                     0 -1 0


   4. Motion Blur - blur during fast
movement.

   Has 2 parameters: length (Length) and
angle (Angle), sets the direction in
which smears.

   For directions from right to left and
Length = 3 the matrix looks like this:



                    0 0 0 0 0

                    0 0 0 0 0

          A = 1 / 3 0 0 1 1 1

                    0 0 0 0 0

                    0 0 0 0 0


 end of part 1.
__________________________________________







Other articles:

Demo-Building - an algorithm to PROCESSING visibility of surfaces 3D-figup.

Demo-Building - Fill the triangle Gupo shading, texture mapping.

Demo-Building - Proetsirvoanie 3D> 2D.

Demo-Building - filtration pastpovyh izobpazheny. An algorithm to postpoeniya bugpyvistyh of surfaces. Flame effect. blurring in fast movement. Sharpening

Digital Design - A new music editor for digital music.

Greetz - Greetings to all who have not yet dropped the most Kulnev complex in the world - Spectrum!!!

Partys - Sonstructions Chaos 1999 about budschem demopati.

Slang - Slenogovy dictionary demoscene.

Turbo / Slow - The scheme uskoryalki and Lagsters com.

Video - Converting animation on the example attribute the video.

Interview - Random / Chaos Constructions.

Interview - An interview with Lithuanian musicians zHenYa / zERo.

From pedaktsii - From the authors.

Application - Pinkword, Digital Desing.

Advertising - Advertising and announcements.


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

Similar articles:
Interview - Interview with Dennis Ritchie (Dennis M. Ritchie) creator of the programming language "C".
List BBS - A list of BBS. Opened a new I.P.S. BBS.
Tape and Disk - Adapting programs to the system TR-DOS (Part 4).
Rest In Pain - On a glitch spoil life.

В этот день...   21 November