i'm trying to implement a gaussian blur using pixilang's convolution filter; i'm using this site as a reference for the implementation: https://aryamansharda.medium.com/image- ... 36db6781b1
as of now, it almost works, except it doesn't look the way i'd expect it to
here's the way it looks now, with pixilang and radius=11:
and here's how i think it should look, using the gimp and the same radius:
here's my code, with some unnecessary stuff commented out:
Code: Select all
cover = load("cover.png")
cover_src = clone(cover)
cover_blur_rad = 11
// gaussian blur
sigma = max((cover_blur_rad / 2), 1)
kernel_width = (2 * cover_blur_rad) + 1
kernel = new(kernel_width, kernel_width, INT)
clean(kernel, 1)
//sum = 0
for (x = -cover_blur_rad ; x < cover_blur_rad ; x + 1) {
for (y = -cover_blur_rad ; y < cover_blur_rad ; y + 1) {
exp_num = -(x * x + y * y)
exp_dem = 2 * sigma * sigma
expression = pow(M_E, exp_num / exp_dem)
ker_val = (expression / (2 * M_PI * sigma * sigma))
kernel[(x + cover_blur_rad), (y + cover_blur_rad)] = ker_val
//sum = sum + ker_val
}
}
/* for (x = 0 ; x < kernel_width ; x + 1) {
for (y = 0 ; y < kernel_width ; y + 1) {
kernel[x, y] = kernel[x, y] / sum
}
} */
conv_filter(cover, cover_src, kernel, kernel_width, 0, CONV_FILTER_COLOR)
while 1
{
pixi( cover, 0, 0 )
while get_event() { if EVT[ EVT_TYPE ] == EVT_QUIT { halt } }
frame()
}
fn max($a, $b) {
if ($a >= $b) {
ret($a)
} else {
ret($b)
}
}
https://ibb.co/QH88nXF
any pointers please? this is my first time working with image convolution
thank you!