Well this is a layman’s attempt on blurring an image, i am not using any specific [already known] alogrithm, i am implementing my own technique.
float k[][5]= { .01, .01, .01, .01, .01,
.01, .01, .01, .01, .01,
.01, .01, .01, .01, .01};
for( row = 0; row < rows; ++row)
{
sum=0;
for ( col = 0; col < cols; ++col)
{
temp_ptr = &((uchar*)(img->imageData + (img->widthStep*row)))[col];
for( i=1; i<6;i++)
{
float factor=exp((float)(-(i-col)*(i-col)/(2*sigma2)));
sum+=factor;
for( j=1; j<6 ;j++)
{
if( (row-j)>0 && (col-i)>0 )
k[i-1][j-1]+=factor*temp_ptr[row-i+col-j];
}
for( j=1; j<6 ;j++)
{
if( (row-j)>0 && (col-i)>0 )
{
uchar* temp_ptr1 = &((uchar*)(img->imageData + (img->widthStep * (row-1) )))[col-1];
temp_ptr1[0]=temp_ptr[0]*k[i-1][j-1]/sum;
temp_ptr1[1]=temp_ptr[1]*k[i-1][j-1]/sum;
temp_ptr1[2]=temp_ptr[2]*k[i-1][j-1]/sum;
}
}
}
}
}
Your
jindex is out of bound for arrayk.It can not be greater than 5 !
In 5th
foryou should change upper bound to5not6.