procedure Blur()
var d:array 1..maxx, 1..maxy of int %vertual image, holds pixel colors
var c:int:=255 %just a variable for color
var cr,cb,cg:array 1..9 of real %temporary colors
var acr,acb,acg:real %used for average color calculation
for x:1..maxx
for y:1..maxy
d(x,y):=whatdotcolor(x,y) %records pixel colors
end for
end for
for x:2..maxx-1
for y:2..maxy-1
RGB.GetColor(d(x-1,y-1),cr(1),cg(1),cb(1))
RGB.GetColor(d(x,y-1),cr(2),cg(2),cb(2))
RGB.GetColor(d(x+1,y-1),cr(3),cg(3),cb(3))
RGB.GetColor(d(x-1,y),cr(4),cg(4),cb(4))
RGB.GetColor(d(x,y),cr(5),cg(5),cb(5))
RGB.GetColor(d(x+1,y),cr(6),cg(6),cb(6))
RGB.GetColor(d(x-1,y+1),cr(7),cg(7),cb(7))
RGB.GetColor(d(x,y+1),cr(8),cg(8),cb(8))
RGB.GetColor(d(x+1,y+1),cr(9),cg(9),cb(9))
acr:=0
for i:1..9
acr+=cr(i)
end for
acr:=acr/9 %average color
acg:=0
for i:1..9
acg+=cg(i)
end for
acg:=acg/9 %average color
acb:=0
for i:1..9
acb+=cb(i)
end for
acb:=acb/9 %average color
RGB.SetColor(c,acr,acg,acb) %create the new color
Draw.Dot(x,y,c) %draw that color
end for
end for
end Blur
|