English
Source / code snippets

Weichzeichnen, filter, Box-Blur

 

Sven
Bader
here have I a code for a Weichzeichen-filter, from performance-Found sooner for small Graphics suitable.



About whom third Parameter the Blur-function can itself steer, How often the filter applied becomes.
Proc Blur

    Parameters width&, height&, passes&
    Declare avg_red&, avg_green&, avg_blue&, new_image&[width&-1, height&-1, 2]
    Declare count&, box&, x&, y&, i&, j&

    whileLoop passes&

        box& = 1

        WhileLoop 0, width& - 1

            i& = &loop

            WhileLoop 0, height& - 1

                j& = &loop
                clear avg_red&, avg_blue&, avg_green&, count&

                WhileLoop (i& - box&), (i& + box&)

                    x& = &loop
                    Case (x& = width&)  : Break
                    Case (x& < 0) : Continue

                    WhileLoop (j& - box&), (j& + box&)

                        y& = &loop
                        case (y& = height&) : Break
                        case (y& < 0) : Continue
                        inc count&
                        avg_red&   = avg_red&   + image&[x&, y&, 0]
                        avg_green& = avg_green& + image&[x&, y&, 1]
                        avg_blue&  = avg_blue&  + image&[x&, y&, 2]

                    EndWhile

                EndWhile

                new_image&[i&, j&, 0] = avg_red&   / count&
                new_image&[i&, j&, 1] = avg_green& / count&
                new_image&[i&, j&, 2] = avg_blue&  / count&

            EndWhile

        EndWhile

        MAT image&[] = new_image&[]

    EndWhile

ENDPROC

Cls
Declare x&, y&, px&, width&, height&
'===================== Image aray reading
DrawIcon "EIS", 50, 50
width& = 32
height& = 32
Declare image&[width&-1, height&-1, 2]

WhileLoop 0, height& - 1

    y& = &loop

    WhileLoop 0, width& - 1

        x& = &loop
        px& = GetPixel(50 + x&, 50 + y&)
        image&[x&, y&, 0] = GetRValue(px&)
        image&[x&, y&, 1] = GetGValue(px&)
        image&[x&, y&, 2] = GetBValue(px&)

    EndWhile

EndWhile

'===================== filter utilize
Blur(width&, height&, 5)
'===================== geglättetes Image Show

WhileLoop 0, height& - 1

    y& = &loop

    WhileLoop 0, width& - 1

        x& = &loop
        SetPixel 100 + x&, y& + 50, RGB(image&[x&, y&, 0], image&[x&, y&, 1], image&[x&, y&, 2])

    EndWhile

EndWhile

WaitKey
End

The Flaschenhals is not once the filter self (where the too) separate the GetPixel and SetPixel. bypass could to the to that example over a 24-bit-Bitmap-File, everybody can as block einliest.

One qualitativer Tweak would, The function only a Teilbereich glätten To let, The Borders but nevertheless in the aray vorzuhalten. then would The Randbereiche not so disjointed looks. For this, should one then The 4 Case-inquire Remove and the x/y-Offset as Parameter mitgeben.

plenty Fun at Glätten

23 kB
Hochgeladen:11/16/21
Downloadcounter77
Download
 
11/16/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.540 Views

Untitledvor 0 min.
Sven Bader12/22/22
Ernst05/29/22
ByteAttack05/20/22
Michael W.03/30/22
More...

Themeninformationen

this Topic has 1 subscriber:

Sven Bader (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie