SOS Flou gausian
Publié : jeu. 16/avr./2020 11:27
Bonjours à tous
Il y aurait il une méthode plus compact et surtout moins coûteux en temps pour effectuer une telle opération s'il vous plait?
voici ci dessous mon code mais j'avoue j'ai un peu honte de son esthétique


Il y aurait il une méthode plus compact et surtout moins coûteux en temps pour effectuer une telle opération s'il vous plait?
voici ci dessous mon code mais j'avoue j'ai un peu honte de son esthétique

Code : Tout sélectionner
UseJPEGImageDecoder()
UsePNGImageDecoder()
imgx=1200
imgy=800
TailleMax = imgx*imgy
If OpenWindow(0, 0, 0, imgx+50, imgy+50, "PixLab", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
pic$ = OpenFileRequester("Image indexe",pic$,"",0)
If pic$ <> ""
If LoadImage(0,pic$)
ResizeImage(0,imgx,imgy,#PB_Image_Smooth)
decal = 1
If CreateImage(3,imgx,imgy,24)
StartDrawing(ImageOutput(3))
DrawImage(ImageID(0),0,0)
For xf=0+decal To imgx-decal-1
For yf=0+decal To imgy-decal-1
a=Point(xf,yf)
b=Point(xf-1,yf)
c=Point(xf,yf-1)
d=Point(xf+1,yf)
e=Point(xf,yf+1)
f=Point(xf-1,yf+1)
g=Point(xf-1,yf-1)
h=Point(xf+1,yf-1)
i=Point(xf+1,yf+1)
ar = Red(a)
ag = Green(a)
ab = Blue(a)
br = Red(b)
bg = Green(b)
bb = Blue(b)
cr = Red(c)
cg = Green(c)
cb = Blue(c)
dr = Red(d)
dg = Green(d)
db = Blue(d)
er = Red(e)
eg = Green(e)
eb = Blue(e)
fr = Red(f)
fg = Green(f)
fb = Blue(f)
gr = Red(g)
gg = Green(g)
gb = Blue(g)
hr = Red(h)
hg = Green(h)
hb = Blue(h)
ir = Red(i)
ig = Green(i)
ib = Blue(i)
R = (ar+br+cr+dr+er+fr+gr+hr+ir)/9
G = (ag+bg+cg+dg+eg+fg+gg+hg+ig)/9
B = (ab+bb+cb+db+eb+fb+gb+hb+ib)/9
If R > 255:R = 255:EndIf
If R < 0:R = 0:EndIf
If G > 255:G = 255:EndIf
If G < 0:G = 0:EndIf
If B > 255:B = 255:EndIf
If B < 0:B = 0:EndIf
Plot(xf,yf,RGB(R,G,B))
Next yf
Next xf
StopDrawing()
ImageGadget(0, 0, 0, imgx, imgy, ImageID(3))
EndIf
Else
Debug "Erreur de chargement"
EndIf
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
