4 General convolution for 2d decoupled filters
5 end effects are acounted for by increasing
6 scaling the result with the sum of used coefficients
8 coeff: (float array) coefficients for filter
9 len: length of filter.. number of coefficients
10 note that this has to be an odd number
11 (since the filter is even);
15 i_conv(i_img *im,const float *coeff,int len) {
21 mm_log((1,"i_conv(im %p, coeff %p, len %d)\n",im,coeff,len));
23 timg = i_sametype(im, im->xsize, im->ysize);
29 /* don't move the calculation of pc up here, it depends on which pixels
31 for(l=0;l<im->ysize;l++) {
32 for(i=0;i<im->xsize;i++) {
34 for(ch=0;ch<im->channels;ch++)
37 if (IM_GPIX(im,i+c-center,l,&rcolor)!=-1) {
38 for(ch=0;ch<im->channels;ch++)
39 res[ch] += (rcolor.channel[ch])*coeff[c];
42 for(ch=0;ch<im->channels;ch++) {
43 double temp = res[ch]/pc;
45 temp < 0 ? 0 : temp > IM_SAMPLE_MAX ? IM_SAMPLE_MAX : (IM_SAMPLE_T)temp;
47 IM_PPIX(timg,i,l,&rcolor);
51 for(l=0;l<im->xsize;l++) {
52 for(i=0;i<im->ysize;i++) {
54 for(ch=0;ch<im->channels;ch++) res[ch]=0;
56 if (IM_GPIX(timg,l,i+c-center,&rcolor)!=-1) {
57 for(ch=0;ch<im->channels;ch++)
58 res[ch] += (rcolor.channel[ch])*coeff[c];
62 for(ch=0;ch<im->channels;ch++) {
63 double temp = res[ch]/pc;
65 temp < 0 ? 0 : temp > IM_SAMPLE_MAX ? IM_SAMPLE_MAX : (IM_SAMPLE_T)temp;
67 IM_PPIX(im,l,i,&rcolor);