Blob Blame Raw



void filterWind(Img *img, Img *pattern, double att) {
  if (!img->data) return;

  for(int x = 0; x < img->w; ++x) {
    double nk = pattern && pattern->data ? imgCubicHCh(pattern, 0, (double)x/img->w*pattern->w, 0) : 1;
    double acc[4] = {};
    double a = 1 - pow(1 - att, nk);
    for(int y = 0; y < img->h; ++y) {
      double *cl = imgPixel(img, x, y);
      for(int c = 0; c < 4; ++c) {
        if (cl[c] < acc[c]) {
          cl[c] = acc[c];
        } else
        if (acc[c] < cl[c]) {
          acc[c] = cl[c];
        }
        acc[c] *= a;
      }
    }
  }
}