Gaussian Smoothing

I have written a gaussian blurring function in c++ (Actually systemC) and i am writing the pixel values to an output file. However my output image has overlapping blurred images. In other words, if the original input image has a single bridge, the image after gaussian smoothing has two blurred bridges side by side within the same frame. Below is the code. Help?
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
#include "gaussianfilter.h"
using namespace std;

void gaussianfilter::blurring() 
{

int i,j,m,n,mm,nn,ii,jj;
float sum;

int gf[5][5];


 gf[0][0] = 2; gf[0][1] = 4; gf[0][2] = 5; gf[0][3] = 4; gf[0][4] = 2;
 gf[1][0] = 4; gf[1][1] = 9; gf[1][2] = 12; gf[1][3] = 9; gf[1][4] = 4;
 gf[2][0] = 5; gf[2][1] = 12; gf[2][2] = 15; gf[2][3] = 12; gf[2][4] = 5;
 gf[3][0] = 4; gf[3][1] = 9; gf[3][2] = 12; gf[3][3] = 9; gf[3][4] = 4;
 gf[4][0] = 2; gf[4][1] = 4; gf[4][2] = 5; gf[4][3] = 4; gf[4][4] = 2;



blurred_data = new int*[512];
for (i=0;i<512;i++)
blurred_data[i] = new int[512];

while (true) {

do {
wait();
}

while (!(inpready == true));

int **data1 = indata.read();

for (i=0;i<pictureWidth.read();i++) {

 for(j=0;j<pictureHeight.read();j++) {

data1[i][j] = (data1[i][j]*gf[0][0] +data1[i][j+1]*gf[0][1] +data1[i][j+2]*gf[0][2] +data1[i][j+3]*gf[0][3] +data1[i][j+4]*gf[0][4] +data1[i+1][j]*gf[1][0] +data1[i+1][j+1]*gf[1][1] +data1[i+1][j+2]*gf[1][2] +data1[i+1][j+3]*gf[1][3] +data1[i+1][j+4]*gf[1][4] +data1[i+2][j]*gf[2][0] +data1[i+2][j+1]*gf[2][1] +data1[i+2][j+2]*gf[2][2] +data1[i+2][j+3]*gf[2][3] +data1[i+2][j+4]*gf[2][4] +data1[i+3][j]*gf[3][0] +data1[i+3][j+1]*gf[3][1] +data1[i+3][j+2]*gf[3][2] +data1[i+3][j+3]*gf[3][3] +data1[i+3][j+4]*gf[3][4] +data1[i+4][j]*gf[4][0] +data1[i+4][j+1]*gf[4][1] +data1[i+4][j+2]*gf[4][2] +data1[i+4][j+3]*gf[4][3] +data1[i+4][j+4]*gf[4][4])/159; 

}


}

for (i=0;i<pictureWidth;i++) {
for (j=0;j<pictureHeight;j++) {    
blurred_data[i][j] = data1[i][j];
}
}

blurred_image.write(data1);
gready.write(true);
wait();

}
}
Topic archived. No new replies allowed.