A short time ago on the internet to see a fast fuzzy algorithm, performance is very good.
SOURCE Blog:
Http://www.lellansin.com/super-fast-blur-%E6%A8%A1%E7%B3%8A%E7%AE%97%E6%B3%95.html
Bloggers have made simple bug fixes and performance optimizations.
This algorithm is used to blur a 5000x3000 image on the host son, which takes only 500-600 milliseconds and is very fast.
The code is as follows:
/** Super Fast Blur v1.1+* Original Author:mario Klingemann (c + + version) * Original Address:http://incubator.quasimondo. com/processing/superfastblur.pde* C version updated by Lellansin (http://www.lellansin.com) * C version bugfix and perform ance optimization by Tntmonks (http://tntmonks.cnblogs.com) */void superfastblur (unsigned char *pix, unsigned int w, unsig Ned int h, unsigned int comp, int radius) {unsigned int div;unsigned int WM, HM, wh;unsigned int *vmin, *vmax;unsigned Char *r, *g, *b, *dv;unsigned int rsum, gsum, bsum;unsigned int p, p1, p2, Yi, yw;int x, y, I, yp;if (RADIUS < 1) return;wm = W-1;HM = H-1;WH = w * H;div = radius + radius + 1;vmin = (unsigned int *) malloc (sizeof (unsigned int) * MAX (W, h)); VM AX = (unsigned int *) malloc (sizeof (unsigned int) * MAX (W, h)); r = (unsigned char *) malloc (sizeof (unsigned char) * wh); g = (unsigned char *) malloc (sizeof (unsigned char) * wh), B = (unsigned char *) malloc (sizeof (unsigned char) * wh);d v = (unsigned char *) malloc (sizeof (Unsigned Char) * * * div); for (i = 0; i < * DIV; i++) dv[i] = (i/div); yw = Yi = 0;for (y = 0; y < h; y++) {rsum = Gsum = Bsum = 0;for (i =-radius; I <= radius; i++) {p = (yi + min (wm, Max (i, 0))) * Comp;bsum + = Pix[p];gsum + + pix[p + 1];rsum + = pix[p + 2];} for (x = 0; x < W; + +) {R[yi] = Dv[rsum];g[yi] = Dv[gsum];b[yi] = dv[bsum];if (y = = 0) {vmin[x] = min (x + radius + 1, WM ); Vmax[x] = max (X-radius, 0);} P1 = (yw + vmin[x]) * Comp;p2 = (yw + vmax[x]) * comp;bsum + = Pix[p1]-Pix[p2];gsum + = PIX[P1 + 1]-pix[p2 + 1];rsum + + PIX[P1 + 2]-pix[p2 + 2];yi++;} yw + = w;} for (x = 0; x < W; + +) {rsum = Gsum = Bsum = 0;YP =-radius * W;for (i =-radius; I <= radius; i++) {yi = max (0, YP) + X;rsum + = r[yi];gsum + g[yi];bsum + = B[yi];yp + W;} Yi = x;for (y = 0; y < h; y++) {Pix[yi * Comp] = (Dv[bsum]);p Ix[yi * Comp + 1] = (Dv[gsum]);p Ix[yi * Comp + 2] = (dv[rs UM]), if (x = = 0) {Vmin[y] = min (y + radius + 1, HM) * W;vmax[y] = max (Y-radius, 0) * W;} P1 = x + vmin[y];p 2 = x + VMax[y];rsum + = R[p1]-r[p2];gsum + = G[p1]-g[p2];bsum + = B[p1]-B[p2];yi + = W;}} Free (R); Free (g); Free (b); Free (VMIN); Free (VMAX); Free (DV);}
The simple modification of the algorithm can be used for image enhancement.
The algorithm can be further optimized, this task is given to you crossing.
Fast Fuzzy algorithm