1. 程式人生 > >圖片處理的幾種演算法(毛玻璃效果,高斯模糊效果,舊時光效果,lomo效果,暖意效果)

圖片處理的幾種演算法(毛玻璃效果,高斯模糊效果,舊時光效果,lomo效果,暖意效果)

毛玻璃效果:高斯模糊效果:

//高斯模糊,毛玻璃
//低於Android4.2可以用Java原生程式碼實現。但是效率會低不少:這完全是一種妥協的方式,不推薦
public Bitmap fastblur(Context context, Bitmap sentBitmap, int radius) {

		Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);

		if (radius < 1) {
			return (null);
		}

		int w = bitmap.getWidth();
		int h = bitmap.getHeight();

		int[] pix = new int[w * h];
		bitmap.getPixels(pix, 0, w, 0, 0, w, h);

		int wm = w - 1;
		int hm = h - 1;
		int wh = w * h;
		int div = radius + radius + 1;

		int r[] = new int[wh];
		int g[] = new int[wh];
		int b[] = new int[wh];
		int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
		int vmin[] = new int[Math.max(w, h)];

		int divsum = (div + 1) >> 1;
		divsum *= divsum;
		int temp = 256 * divsum;
		int dv[] = new int[temp];
		for (i = 0; i < temp; i++) {
			dv[i] = (i / divsum);
		}

		yw = yi = 0;

		int[][] stack = new int[div][3];
		int stackpointer;
		int stackstart;
		int[] sir;
		int rbs;
		int r1 = radius + 1;
		int routsum, goutsum, boutsum;
		int rinsum, ginsum, binsum;

		for (y = 0; y < h; y++) {
			rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
			for (i = -radius; i <= radius; i++) {
				p = pix[yi + Math.min(wm, Math.max(i, 0))];
				sir = stack[i + radius];
				sir[0] = (p & 0xff0000) >> 16;
				sir[1] = (p & 0x00ff00) >> 8;
				sir[2] = (p & 0x0000ff);
				rbs = r1 - Math.abs(i);
				rsum += sir[0] * rbs;
				gsum += sir[1] * rbs;
				bsum += sir[2] * rbs;
				if (i > 0) {
					rinsum += sir[0];
					ginsum += sir[1];
					binsum += sir[2];
				} else {
					routsum += sir[0];
					goutsum += sir[1];
					boutsum += sir[2];
				}
			}
			stackpointer = radius;

			for (x = 0; x < w; x++) {

				r[yi] = dv[rsum];
				g[yi] = dv[gsum];
				b[yi] = dv[bsum];

				rsum -= routsum;
				gsum -= goutsum;
				bsum -= boutsum;

				stackstart = stackpointer - radius + div;
				sir = stack[stackstart % div];

				routsum -= sir[0];
				goutsum -= sir[1];
				boutsum -= sir[2];

				if (y == 0) {
					vmin[x] = Math.min(x + radius + 1, wm);
				}
				p = pix[yw + vmin[x]];

				sir[0] = (p & 0xff0000) >> 16;
				sir[1] = (p & 0x00ff00) >> 8;
				sir[2] = (p & 0x0000ff);

				rinsum += sir[0];
				ginsum += sir[1];
				binsum += sir[2];

				rsum += rinsum;
				gsum += ginsum;
				bsum += binsum;

				stackpointer = (stackpointer + 1) % div;
				sir = stack[(stackpointer) % div];

				routsum += sir[0];
				goutsum += sir[1];
				boutsum += sir[2];

				rinsum -= sir[0];
				ginsum -= sir[1];
				binsum -= sir[2];

				yi++;
			}
			yw += w;
		}
		for (x = 0; x < w; x++) {
			rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
			yp = -radius * w;
			for (i = -radius; i <= radius; i++) {
				yi = Math.max(0, yp) + x;

				sir = stack[i + radius];

				sir[0] = r[yi];
				sir[1] = g[yi];
				sir[2] = b[yi];

				rbs = r1 - Math.abs(i);

				rsum += r[yi] * rbs;
				gsum += g[yi] * rbs;
				bsum += b[yi] * rbs;

				if (i > 0) {
					rinsum += sir[0];
					ginsum += sir[1];
					binsum += sir[2];
				} else {
					routsum += sir[0];
					goutsum += sir[1];
					boutsum += sir[2];
				}

				if (i < hm) {
					yp += w;
				}
			}
			yi = x;
			stackpointer = radius;
			for (y = 0; y < h; y++) {
				pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16)
						| (dv[gsum] << 8) | dv[bsum];

				rsum -= routsum;
				gsum -= goutsum;
				bsum -= boutsum;

				stackstart = stackpointer - radius + div;
				sir = stack[stackstart % div];

				routsum -= sir[0];
				goutsum -= sir[1];
				boutsum -= sir[2];

				if (x == 0) {
					vmin[y] = Math.min(y + r1, hm) * w;
				}
				p = x + vmin[y];

				sir[0] = r[p];
				sir[1] = g[p];
				sir[2] = b[p];

				rinsum += sir[0];
				ginsum += sir[1];
				binsum += sir[2];

				rsum += rinsum;
				gsum += ginsum;
				bsum += binsum;

				stackpointer = (stackpointer + 1) % div;
				sir = stack[stackpointer];

				routsum += sir[0];
				goutsum += sir[1];
				boutsum += sir[2];

				rinsum -= sir[0];
				ginsum -= sir[1];
				binsum -= sir[2];

				yi += w;
			}
		}

		bitmap.setPixels(pix, 0, w, 0, 0, w, h);
		return (bitmap);
	}
// RenderScript的這個方法需要Android API17

private void blur(Bitmap bkg, View view, float radius) {
    Bitmap overlay = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.drawBitmap(bkg, -view.getLeft(), -view.getTop(), null);
    RenderScript rs = RenderScript.create(this);
    Allocation overlayAlloc = Allocation.createFromBitmap(rs, overlay);
    ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, overlayAlloc.getElement());
    blur.setInput(overlayAlloc);
    blur.setRadius(radius);
    blur.forEach(overlayAlloc);
    overlayAlloc.copyTo(overlay);
    view.setBackground(new BitmapDrawable(getResources(), overlay));
    rs.destroy();
}

//api在16以上,可以使用系統提供的方法直接處理圖片
if (VERSION.SDK_INT > 16) {
    Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
    final RenderScript rs = RenderScript.create(context);
    final Allocation input = Allocation.createFromBitmap(rs, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE,
            Allocation.USAGE_SCRIPT);
    final Allocation output = Allocation.createTyped(rs, input.getType());
    final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    script.setRadius(radius /* e.g. 3.f */);
    script.setInput(input);
    script.forEach(output);
    output.copyTo(bitmap);
    return bitmap;
}

//C 語言實現
static int* StackBlur(int* pix, int w, int h, int radius) {
    int wm = w - 1;
    int hm = h - 1;
    int wh = w * h;
    int div = radius + radius + 1;
    int *r = (int *)malloc(wh * sizeof(int));
    int *g = (int *)malloc(wh * sizeof(int));
    int *b = (int *)malloc(wh * sizeof(int));
    int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
    int *vmin = (int *)malloc(MAX(w,h) * sizeof(int));
    int divsum = (div + 1) >> 1;
    divsum *= divsum;
    int *dv = (int *)malloc(256 * divsum * sizeof(int));
    for (i = 0; i < 256 * divsum; i++) {
        dv[i] = (i / divsum);
    }
    yw = yi = 0;
    int(*stack)[3] = (int(*)[3])malloc(div * 3 * sizeof(int));
    int stackpointer;
    int stackstart;
    int *sir;
    int rbs;
    int r1 = radius + 1;
    int routsum, goutsum, boutsum;
    int rinsum, ginsum, binsum;
    for (y = 0; y < h; y++) {
        rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
        for (i = -radius; i <= radius; i++) {
            p = pix[yi + (MIN(wm, MAX(i, 0)))];
            sir = stack[i + radius];
            sir[0] = (p & 0xff0000) >> 16;
            sir[1] = (p & 0x00ff00) >> 8;
            sir[2] = (p & 0x0000ff);
            rbs = r1 - ABS(i);
            rsum += sir[0] * rbs;
            gsum += sir[1] * rbs;
            bsum += sir[2] * rbs;
            if (i > 0) {
                rinsum += sir[0];
                ginsum += sir[1];
                binsum += sir[2];
            }
            else {
                routsum += sir[0];
                goutsum += sir[1];
                boutsum += sir[2];
            }
        }
        stackpointer = radius;
        for (x = 0; x < w; x++) {
            r[yi] = dv[rsum];
            g[yi] = dv[gsum];
            b[yi] = dv[bsum];
            rsum -= routsum;
            gsum -= goutsum;
            bsum -= boutsum;
            stackstart = stackpointer - radius + div;
            sir = stack[stackstart % div];
            routsum -= sir[0];
            goutsum -= sir[1];
            boutsum -= sir[2];
            if (y == 0) {
                vmin[x] = MIN(x + radius + 1, wm);
            }
            p = pix[yw + vmin[x]];
            sir[0] = (p & 0xff0000) >> 16;
            sir[1] = (p & 0x00ff00) >> 8;
            sir[2] = (p & 0x0000ff);
            rinsum += sir[0];
            ginsum += sir[1];
            binsum += sir[2];
            rsum += rinsum;
            gsum += ginsum;
            bsum += binsum;
            stackpointer = (stackpointer + 1) % div;
            sir = stack[(stackpointer) % div];
            routsum += sir[0];
            goutsum += sir[1];
            boutsum += sir[2];
            rinsum -= sir[0];
            ginsum -= sir[1];
            binsum -= sir[2];
            yi++;
        }
        yw += w;
    }
    for (x = 0; x < w; x++) {
        rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
        yp = -radius * w;
        for (i = -radius; i <= radius; i++) {
            yi = MAX(0, yp) + x;
            sir = stack[i + radius];
            sir[0] = r[yi];
            sir[1] = g[yi];
            sir[2] = b[yi];
            rbs = r1 - ABS(i);
            rsum += r[yi] * rbs;
            gsum += g[yi] * rbs;
            bsum += b[yi] * rbs;
            if (i > 0) {
                rinsum += sir[0];
                ginsum += sir[1];
                binsum += sir[2];
            }
            else {
                routsum += sir[0];
                goutsum += sir[1];
                boutsum += sir[2];
            }
            if (i < hm) {
                yp += w;
            }
        }
        yi = x;
        stackpointer = radius;
        for (y = 0; y < h; y++) {
            // Preserve alpha channel: ( 0xff000000 & pix[yi] )
            pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
            rsum -= routsum;
            gsum -= goutsum;
            bsum -= boutsum;
            stackstart = stackpointer - radius + div;
            sir = stack[stackstart % div];
            routsum -= sir[0];
            goutsum -= sir[1];
            boutsum -= sir[2];
            if (x == 0) {
                vmin[y] = MIN(y + r1, hm) * w;
            }
            p = x + vmin[y];
            sir[0] = r[p];
            sir[1] = g[p];
            sir[2] = b[p];
            rinsum += sir[0];
            ginsum += sir[1];
            binsum += sir[2];
            rsum += rinsum;
            gsum += ginsum;
            bsum += binsum;
            stackpointer = (stackpointer + 1) % div;
            sir = stack[stackpointer];
            routsum += sir[0];
            goutsum += sir[1];
            boutsum += sir[2];
            rinsum -= sir[0];
            ginsum -= sir[1];
            binsum -= sir[2];
            yi += w;
        }
    }
    free(r);
    free(g);
    free(b);
    free(vmin);
    free(dv);
    free(stack);
    return(pix);
}

//高斯模糊
public static void gaussBlur(int[] data, int width, int height, int radius,float sigma) {

	float pa = (float) (1 / (Math.sqrt(2 * Math.PI) * sigma));
	float pb = -1.0f / (2 * sigma * sigma);

	// generate the Gauss Matrix
	float[] gaussMatrix = new float[radius * 2 + 1];
	float gaussSum = 0f;
	for (int i = 0, x = -radius; x <= radius; ++x, ++i) {
		float g = (float) (pa * Math.exp(pb * x * x));
		gaussMatrix[i] = g;
		gaussSum += g;
	}

	for (int i = 0, length = gaussMatrix.length; i < length; ++i) {
		gaussMatrix[i] /= gaussSum;
	}

	// x direction
	for (int y = 0; y < height; ++y) {
		for (int x = 0; x < width; ++x) {
			float r = 0, g = 0, b = 0;
			gaussSum = 0;
			for (int j = -radius; j <= radius; ++j) {
				int k = x + j;
				if (k >= 0 && k < width) {
					int index = y * width + k;
					int color = data[index];
					int cr = (color & 0x00ff0000) >> 16;
					int cg = (color & 0x0000ff00) >> 8;
					int cb = (color & 0x000000ff);

					r += cr * gaussMatrix[j + radius];
					g += cg * gaussMatrix[j + radius];
					b += cb * gaussMatrix[j + radius];

					gaussSum += gaussMatrix[j + radius];
				}
			}

			int index = y * width + x;
			int cr = (int) (r / gaussSum);
			int cg = (int) (g / gaussSum);
			int cb = (int) (b / gaussSum);
			
			data[index] = cr << 16 | cg << 8 | cb | 0xff000000;
		}
	}

	// y direction
	for (int x = 0; x < width; ++x) {
		for (int y = 0; y < height; ++y) {
			float r = 0, g = 0, b = 0;
			gaussSum = 0;
			for (int j = -radius; j <= radius; ++j) {
				int k = y + j;
				if (k >= 0 && k < height) {
					int index = k * width + x;
					int color = data[index];
					int cr = (color & 0x00ff0000) >> 16;
					int cg = (color & 0x0000ff00) >> 8;
					int cb = (color & 0x000000ff);

					r += cr * gaussMatrix[j + radius];
					g += cg * gaussMatrix[j + radius];
					b += cb * gaussMatrix[j + radius];

					gaussSum += gaussMatrix[j + radius];
				}
			}

			int index = y * width + x;
			int cr = (int) (r / gaussSum);
			int cg = (int) (g / gaussSum);
			int cb = (int) (b / gaussSum);
			data[index] = cr << 16 | cg << 8 | cb | 0xff000000;
		}
	}
}




舊時光效果:

/**
* 舊時光特效
*
* @param bmp
*            原圖片
* @return 舊時光特效圖片
*/
public static Bitmap oldTimeFilter (Bitmap bmp)
{
    int width = bmp.getWidth();
    int height = bmp.getHeight();
    Bitmap bitmap = Bitmap.createBitmap (width, height, Bitmap.Config.RGB_565);
    int pixColor = 0;
    int pixR = 0;
    int pixG = 0;
    int pixB = 0;
    int newR = 0;
    int newG = 0;
    int newB = 0;
    int[] pixels = new int[width * height];
    bmp.getPixels (pixels, 0, width, 0, 0, width, height);
    for (int i = 0; i < height; i++)
    {
        for (int k = 0k < width; k++)
        {
            pixColor = pixels[width * i + k];
            pixR = Color.red (pixColor);
            pixG = Color.green (pixColor);
            pixB = Color.blue (pixColor);
            newR = (int) (0.393 * pixR + 0.769 * pixG + 0.189 * pixB);
            newG = (int) (0.349 * pixR + 0.686 * pixG + 0.168 * pixB);
            newB = (int) (0.272 * pixR + 0.534 * pixG + 0.131 * pixB);
            int newColor = Color.argb (255, newR > 255 ? 255 : newR, newG > 255 ? 255 : newG, newB > 255 ? 255 : newB);
            pixels[width * i + k] = newColor;
        }
    }
    bitmap.setPixels (pixels, 0, width, 0, 0, width, height);
    return bitmap;
}



暖意效果:

/**
* 暖意特效
*
* @param bmp
*            原圖片
* @param centerX
*            光源橫座標
* @param centerY
*            光源縱座標
* @return 暖意特效圖片
*/
public static Bitmap warmthFilter (Bitmap bmp, int centerX, int centerY)
{
    final int width = bmp.getWidth();
    final int height = bmp.getHeight();
    Bitmap bitmap = Bitmap.createBitmap (width, height, Bitmap.Config.RGB_565);
    int pixR = 0;
    int pixG = 0;
    int pixB = 0;
    int pixColor = 0;
    int newR = 0;
    int newG = 0;
    int newB = 0;
    int radius = Math.min (centerX, centerY);
    final float strength = 150F;
    // 光照強度 100~150
    int[] pixels = new int[width * height];
    bmp.getPixels (pixels, 0, width, 0, 0, width, height);
    int pos = 0;
    for (int i = 1, length = height - 1; i < length; i++)
    {
        for (int k = 1, len = width - 1; k < len; k++)
        {
            pos = i * width + k;
            pixColor = pixels[pos];
            pixR = Color.red (pixColor);
            pixG = Color.green (pixColor);
            pixB = Color.blue (pixColor);
            newR = pixR;
            newG = pixG;
            newB = pixB;
            // 計算當前點到光照中心的距離,平面座標系中求兩點之間的距離
            int distance = (int) (Math.pow ( (centerY - i), 2) + Math.pow (centerX - k, 2) );
            if (distance < radius * radius)
            {
                // 按照距離大小計算增加的光照值
                int result = (int) (strength * (1.0 - Math.sqrt (distance) / radius) );
                newR = pixR + result;
                newG = pixG + result;
                newB = pixB + result;
            }
            newR = Math.min (255, Math.max (0, newR) );
            newG = Math.min (255, Math.max (0, newG) );
            newB = Math.min (255, Math.max (0, newB) );
            pixels[pos] = Color.argb (255, newR, newG, newB);
        }
    }
    bitmap.setPixels (pixels, 0, width, 0, 0, width, height);

    return bitmap;
}



lomo效果

/**
* LOMO特效
*
* @param bitmap
*            原圖片
* @return LOMO特效圖片
*/
public static Bitmap lomoFilter (Bitmap bitmap)
{
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int dst[] = new int[width * height];
    bitmap.getPixels (dst, 0, width, 0, 0, width, height);
    int ratio = width > height ? height * 32768 / width : width * 32768 / height;
    int cx = width >> 1;
    int cy = height >> 1;
    int max = cx * cx + cy * cy;
    int min = (int) (max * (1 - 0.8f) );
    int diff = max - min;
    int ri, gi, bi;
    int dx, dy, distSq, v;
    int R, G, B;
    int value;
    int pos, pixColor;
    int newR, newG, newB;
    for (int y = 0; y < height; y++)
    {

        for (int x = 0; x < width; x++)
        {
            pos = y * width + x;
            pixColor = dst[pos];
            R = Color.red (pixColor);
            G = Color.green (pixColor);
            B = Color.blue (pixColor);
            value = R < 128 ? R : 256 - R;
            newR = (value * value * value) / 64 / 256;
            newR = (R < 128 ? newR : 255 - newR);
            value = G < 128 ? G : 256 - G;
            newG = (value * value) / 128;
            newG = (G < 128 ? newG : 255 - newG);
            newB = B / 2 + 0x25;
            // ==========邊緣黑暗==============//
            dx = cx - x;
            dy = cy - y;
            if (width > height)
            {
                dx = (dx * ratio) >> 15;
            }
            else
            {
                dy = (dy * ratio) >> 15;
            }
            distSq = dx * dx + dy * dy;
            if (distSq > min)
            {
                v = ( (max - distSq) << 8) / diff;
                v *= v;
                ri = newR * v >> 16;
                gi = newG * v >> 16;
                bi = newB * v >> 16;
                newR = ri > 255 ? 255 : (ri < 0 ? 0 : ri);
                newG = gi > 255 ? 255 : (gi < 0
                                         ? 0 : gi);
                newB = bi > 255 ? 255 : (bi < 0 ? 0 : bi);
            }
            // ==========邊緣黑暗end==============//
            dst[pos] = Color.rgb (newR, newG, newB);
        }
    }
    Bitmap acrossFlushBitmap = Bitmap.createBitmap (width, height, Bitmap.Config.RGB_565);
    acrossFlushBitmap.setPixels (dst, 0, width, 0, 0, width, height);
    return acrossFlushBitmap;
}





高斯模糊效果:

相關推薦

圖片處理演算法(毛玻璃效果模糊效果時光效果lomo效果暖意效果)

毛玻璃效果:高斯模糊效果: //高斯模糊,毛玻璃 //低於Android4.2可以用Java原生程式碼實現。但是效率會低不少:這完全是一種妥協的方式,不推薦 public Bitmap fastblur(Context context, Bitmap sentBitma

Unity shader學習之屏幕後期處理效果模糊

歸一化 length spl 學習 baidu 一個 one ogr stat 高斯模糊,見 百度百科。 也使用卷積來實現,每個卷積元素的公式為: 其中б是標準方差,一般取值為1。 x和y分別對應當前位置到卷積中心的整數距離。 由於需要對高斯核中的權重進行歸一化,即使所有權

Glide中MultiTransformation使用,實現多種變換效果組合(圓形圓角模糊黑白...)

Glide中MultiTransformation使用 MultiTransformation可以實現多個Transformation效果結合實現一些需求 1、例如Glide載入一張圖片,我們需要把這張

普通模糊動感模糊模糊演算法實現

     模糊演算法在實際應用中經常回碰到,這裡總結下幾種模糊演算法,以便將來的需要。      #ifdef GL_ES precision mediump float; #endif uniform float mode;//0普通模糊 1高斯模糊 2動感模糊 unif

CSS實現背景模糊效果模糊

px值越大,越模糊,可以按照不同的類名給不同的模糊值,背景看起來會更好看一點 重點實現為: -webkit-filter: blur(10px); /* Chrome, Opera */ -moz-filter: blur(10px); -ms-

影象處理五:python讀取圖片方式

一、讀取圖片方式          PIL、opencv、scikit-image: (1)PIL和Pillow只提供最基礎的數字影象處理,功能有限; (2)opencv實際上是一個c++庫,只是提供了python介面,更新速度非常慢

在android中畫圓形圖片辦法

http hub image art 鋸齒 tar ets oid tex 在開發中常常會有一些需求,比方顯示頭像,顯示一些特殊的需求,將圖片顯示成圓角或者圓形或者其它的一些形狀。可是往往我們手上的圖片或者從server獲取到的圖片都是方形的。這時候就須要我們自

Python 下載圖片方法

load color quest content 利用 pytho get .com 圖片 總結下: url = ‘http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1707/31/c14/54293429_

matlab 保存圖片方式

type 保存 get light gb2 方法 figure tex ram 最近在寫畢業論文, 需要保存一些高分辨率的圖片. 下面介紹幾種MATLAB保存圖片的 方式. 一. 直接使用MATLAB的保存按鍵來保存成各種格式的圖片 你可以選擇保存成各種格式的圖片, 實

iOS關於載入圖片方式選擇

最近在開發過程中遇到一些效能優化的東西,這次來說說關於圖片載入的效能優化和選擇。 大家都知道建立UIImage常用以下幾種方式 + (nullable UIImage *)imageNamed:(NSString *)name; // load from main bundle

LaTeX文件插入圖片常用方法

LaTeX中一般只直接支援插入eps(Encapsulated PostScript)格式的圖形檔案, 因此在圖片插入latex文件之前應先設法得到圖片的eps格式的檔案. UNIX下的各種應用軟體都可以把其結果輸出為ps格式, 大部分軟體也可以輸出eps格式. 若軟體只能輸出ps

無重新整理上傳圖片方式

背景知識: 無重新整理上傳圖片主要還是為了在提交表單之前進行圖片的預覽。使用者體驗相對於提交表單跳轉顯示圖片的方式總還是要好一些的。 本文主要介紹三種無重新整理上傳圖片的方式   1.使用iframe子頁面的形式達到無重新整理上傳圖片的功能。首先設定一個隱藏的i

05 識別毒酒——演算法和編碼方式的分析和比較

說明 問題 識別毒酒 方法1 視為一個有約束的最優化問題進行求解 1 模型的進一步討論 3方法2 使用編碼的方法 1 結論 2 具體方法 3一個瑕疵和改進的方法

C#圖片處理3級應用(縮略圖清晰度、圖片剪裁、圖片水印)

圖片資源 img floor getheight adjust format 模版 大於 目錄 利用C#圖片處理的一些基本和高級應用,解決了顯示排版時想讓相片縮略圖列表非常統一、整齊、和美觀,每張縮略圖大小固定為120 x 90且不拉伸變形,用戶頭像讓縮略圖比原圖更清晰

C#圖片處理3高階應用(縮圖清晰度、圖片剪裁、圖片水印)

利用C#圖片處理的一些基本和高階應用,解決了顯示排版時想讓相片縮圖列表非常統一、整齊、和美觀,每張縮圖大小固定為120 x 90且不拉伸變形,使用者頭像讓縮圖比原圖更清晰,上傳的圖片下加一個半透明的LOGO水印等等要求。 高縮圖清晰度 之前一直認為縮圖不可能比原圖清晰,直到某天一位產品的同事給

網頁中預設圖片解決方式

現在網頁中圖片隨處可見,但避免不了有時會出現圖片資源失敗的情況,在谷歌瀏覽器中就會顯示這樣 <img src="logo.jpg" alt="logo"> 這裡的alt屬性是為了當圖片載入失敗時告訴使用者圖片資訊的 能不能美化一下呢? 下面給出幾種

擁塞控制的演算法

在某段時間內,對網路中的資源(鏈路容量,交換節點中的快取和處理機等)需求大於可用的,就會造成擁塞。 擁塞控制就是防止過多的資料注入到網路中造成擁塞,是路由器或鏈路不會過載。 擁塞控制和流量控制的區別: 擁塞控制是一個全域性性的過程,涉及所有主機和路由器,以

iOS 畫圓圖片方法

方法一: self.cycleImv= [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 50, 50)]; [self.view addSubview:self.cycleImv]; // 為圖片切圓 self.

NLP-關鍵詞抽取的演算法

TextRank 從PageRank PageRank的思想是這樣的: 求解網頁的重要性就是求解有向圖中節點的重要性,或者說節點的權重。圖中節點的重要性和節點的入度有關,越多的其他節點連線到該節點說明該節點的重要性越大。因此,節點的重要性與節點的入度有

js實現常見的演算法(陣列去重、字元統計、二分查詢等)

1、陣列去重:利用物件屬性進行篩選 function filter(arr){ let obj={}; let newArr=[]; for (let i=0;i<arr.