+#define IMAGER_NO_CONTEXT
#include "imager.h"
#include "imageri.h"
end effects are acounted for by increasing
scaling the result with the sum of used coefficients
- coeff: (float array) coefficients for filter
+ coeff: (double array) coefficients for filter
len: length of filter.. number of coefficients
note that this has to be an odd number
(since the filter is even);
int
i_conv(i_img *im, const double *coeff,int len) {
- int xo, yo; /* output pixel co-ordinate */
+ i_img_dim xo, yo; /* output pixel co-ordinate */
int c, ch, center;
double pc;
double res[MAXCHANNELS];
i_img *timg;
+ dIMCTXim(im);
- mm_log((1,"i_conv(im %p, coeff %p, len %d)\n",im,coeff,len));
- i_clear_error();
+ im_log((aIMCTX,1,"i_conv(im %p, coeff %p, len %d)\n",im,coeff,len));
+ im_clear_error(aIMCTX);
+
+ if (len < 1) {
+ im_push_error(aIMCTX, 0, "there must be at least one coefficient");
+ return 0;
+ }
center=(len-1)/2;
for(ch = 0;ch < im->channels; ch++)
res[ch] = 0;
for(c = 0;c < len; c++) {
- int xi = xo + c - center;
+ i_img_dim xi = xo + c - center;
if (xi < 0)
xi = 0;
else if (xi >= im->xsize)
for(ch = 0; ch < im->channels; ch++)
res[ch] = 0;
for(c = 0; c < len; c++) {
- int yi = yo + c - center;
+ i_img_dim yi = yo + c - center;
if (yi < 0)
yi = 0;
else if (yi >= im->ysize)