forked from ugocapeto/thepainter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gaussian_blur_rgb_image.c
75 lines (58 loc) · 1.09 KB
/
gaussian_blur_rgb_image.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "header.h"
void gaussian_blur_rgb_image(
int *inp_image_arr,
int xdim,
int ydim,
double sigma,
int precision,
int *out_image_arr
)
{
int *I;
int i;
int j;
int ind;
int *I_out;
int cind;
/*
Allocate memory to store image intensity for each channel
*/
I= (int *)calloc(xdim*ydim,sizeof(int));
/*
Allocate memory to store blurred image intensity for each channel
*/
I_out= (int *)calloc(xdim*ydim,sizeof(int));
/*
Process one channel at a time
*/
for ( cind= 0 ; cind< 3 ; cind++ ) {
for ( i= 0 ; i< ydim ; i++ ) {
for ( j= 0 ; j< xdim ; j++ ) {
ind= i*xdim+j;
I[ind]= inp_image_arr[3*ind+cind];
}
}
gaussian_blur_image(
I,
xdim,
ydim,
sigma,
precision,
I_out
);
for ( i= 0 ; i< ydim ; i++ ) {
for ( j= 0 ; j< xdim ; j++ ) {
ind= i*xdim+j;
out_image_arr[3*ind+cind]= I_out[ind];
}
}
}
/*
Free memory to store image intensity for each channel
*/
free(I);
/*
Free memory to store blurred image intensity for each channel
*/
free(I_out);
}