随笔分类 -  图片处理

摘要:最近在做一款叫叽叽的App(男银懂的),其中有一个功能需要对图片处理实现毛玻璃的特效进过一番预研,找到了3中实现方案,其中各有优缺点:1、如果系统的api在16以上,可以使用系统提供的方法直接处理图片if (VERSION.SDK_INT > 16) { Bitmap bitm... 阅读全文
posted @ 2014-09-28 11:38 lipeil 阅读(26941) 评论(3) 推荐(0)
摘要:1、描述:计算翻开的卡片到平面的投影来模拟卡片打开的效果 。视点位于卡片上边缘中点正上方。 以w、h表示原卡片的宽高,w1、h1表示投影的宽高,H表示视点高度 , a为翻开的卡片与平面上的卡片夹角,有以下公式:h1 = h*cosa *H /(H-h*sina)w1 = w*H/(H-h*sina)投影计算算法(这里仅考虑了第一象限)为: public ImageBuffer openCard(int[] pixels, int width, int height, double pi) { final int H = width * 3; double... 阅读全文
posted @ 2012-12-07 15:29 lipeil 阅读(911) 评论(0) 推荐(0)
摘要:1、算法第一步:从右下到左上遍历图片像素第二步:获取当前像素和 左上点像素,分别取它们RGB的差值第三步:获取三个差值中绝对值最大的一个作为灰度值第四步:将该灰度值加128 ,并且作像素安全处理(即gray = gray>255?255:gray , gray = gray<0 ? 0 : gray)第五步:使用该灰度值创建图片2、实现代码public Bitmap render(Bitmap bitmap) { if (bitmap == null) return null;// bitmap = toGray(bitmap); ... 阅读全文
posted @ 2012-09-28 09:25 lipeil 阅读(691) 评论(0) 推荐(0)
摘要:1、算法r = r*128/(g+b +1);g = g*128/(r+b +1);b = b*128/(g+r +1);2、代码实现public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels ,0 , width , 0 , 0 ,... 阅读全文
posted @ 2012-09-21 14:44 lipeil 阅读(306) 评论(0) 推荐(0)
摘要:1、算法r = Math.sqrt((r- rightr)^2 + (r-bottomr)^2)*2g = Math.sqrt((g- rightg)^2 + (g-bottomg)^2)*2b = Math.sqrt((b- rightb)^2 + (b-bottomb)^2)*22、代码实现 public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[]... 阅读全文
posted @ 2012-09-21 11:48 lipeil 阅读(599) 评论(0) 推荐(0)
摘要:1、算法R = |g – b + g + r| * r / 256G = |b – g + b + r| * r / 256;B = |b – g + b + r| * g / 256;然后灰化。2、代码实现 public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap... 阅读全文
posted @ 2012-09-21 11:14 lipeil 阅读(487) 评论(0) 推荐(0)
摘要:float mSize = 0.5f; public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; final int SIZE = 32768; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int ratio = width >height ? height * SIZE /width : width * SIZE/height;//这里有额外*2^15 用于放大比率;之后的比率使用时需要右移15位... 阅读全文
posted @ 2012-09-21 10:43 lipeil 阅读(6769) 评论(0) 推荐(0)
摘要:1、算法将对rgb 值依次做better处理,同时再下一步用到上一步已经处理好的值。 public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels ,0 , width , 0 , 0 , width , height); for... 阅读全文
posted @ 2012-09-20 20:19 lipeil 阅读(652) 评论(0) 推荐(0)
摘要:1、怀旧特效算法:r = 0.393r +0.769g+0.189bg = 0.349r + 0.686g +0.168bb = 0.272r +0.534g +0.131b2、算法的一般实现: public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPix... 阅读全文
posted @ 2012-09-20 16:08 lipeil 阅读(401) 评论(0) 推荐(0)
摘要:public static Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight(); width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmpGrayscale); ... 阅读全文
posted @ 2012-09-01 19:12 lipeil 阅读(1440) 评论(0) 推荐(0)
摘要:1、原图片去色int[] getGray(int[] pixels, int width, int height) { int gray[] = new int[width * height]; for (int i = 0; i < width - 1; i++) { for (int j = 0; j < height - 1; j++) { int index = width * j + i; int rgba = pixels[inde... 阅读全文
posted @ 2012-08-28 17:54 lipeil 阅读(2496) 评论(0) 推荐(0)