Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
42
Task/Image-convolution/FreeBASIC/image-convolution.basic
Normal file
42
Task/Image-convolution/FreeBASIC/image-convolution.basic
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
Const ancho = 208
|
||||
Const alto = 228
|
||||
|
||||
Dim TamImag(ancho - 1, alto - 1, 2) As Integer
|
||||
|
||||
Screenres ancho, alto, 32
|
||||
|
||||
Bload "i:\Lena.bmp", 0
|
||||
|
||||
Dim As Integer filter(2, 2) => {{-1, -1, -1}, {-1, 12, -1}, {-1, -1, -1}}
|
||||
|
||||
Dim As Integer y, x, i, j, r, g, b, c, f
|
||||
For y = 1 To alto - 2
|
||||
For x = 1 To ancho - 2
|
||||
r = 0 : g = 0 : b = 0
|
||||
For i = -1 To 1
|
||||
For j = -1 To 1
|
||||
c = Point(x + i, y + j)
|
||||
f = filter(i + 1, j + 1)
|
||||
r += f * (c And &HFF)
|
||||
g += f * ((c Shr 8) And &HFF)
|
||||
b += f * ((c Shr 16) And &HFF)
|
||||
Next j
|
||||
Next i
|
||||
If r < 0 Then r = 0 Else If r > 1020 Then r = 1020
|
||||
If g < 0 Then g = 0 Else If g > 1020 Then g = 1020
|
||||
If b < 0 Then b = 0 Else If b > 1020 Then b = 1020
|
||||
TamImag(x, y, 0) = r \ 4
|
||||
TamImag(x, y, 1) = g \ 4
|
||||
TamImag(x, y, 2) = b \ 4
|
||||
Next x
|
||||
Next y
|
||||
|
||||
For y = 0 To alto - 1
|
||||
For x = 0 To ancho - 1
|
||||
Pset (x, y), Rgb(TamImag(x, y, 0), TamImag(x, y, 1), TamImag(x, y, 2))
|
||||
Next x
|
||||
Next y
|
||||
|
||||
Bsave "i:\LenaConvolution.bmp", 0
|
||||
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue