国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > Android > 正文

Android圖像處理之霓虹濾鏡效果

2019-12-12 04:34:52
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

霓虹是用來(lái)描繪圖像的輪廓,勾畫(huà)出顏色變化的邊緣,加強(qiáng)其過(guò)度效果,使圖像產(chǎn)生輪廓發(fā)光的效果。
主要步驟為

1、根據(jù)當(dāng)前像素與其右方和下方像素的梯度運(yùn)算;
2、然后將結(jié)果值作為當(dāng)前像素值,即將原圖當(dāng)前下像素的RGB分量與其右方和下方像素做梯度 運(yùn)算(差的平方和平方根);
3、然后將梯度值作為處理后的像素的RGB三個(gè)分量;

用代碼實(shí)現(xiàn)如下:

//霓虹 public static Bitmap Neon(Bitmap bitmap){   int w = bitmap.getWidth();   int h = bitmap.getHeight();    Bitmap resultBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);   int color = 0;   int r,g,b,r1,g1,b1,r2,g2,b2;    int[] oldPx = new int[w * h];   int[] newPx = new int[w * h];    bitmap.getPixels(oldPx, 0, w, 0, 0, w, h);   for(int y = 0; y < h - 1; y++){     for(int x = 0; x < w - 1; x++){       color = oldPx[x+y*w];        r = (color >> 16) & 0xFF;       g = (color >> 8) & 0xFF;       b = (color >> 0) & 0xFF;        int newcolor = oldPx[x+1+y*w];        r1 = (newcolor >> 16) & 0xFF;       g1 = (newcolor >> 8) & 0xFF;       b1 = (newcolor >> 0) & 0xFF;        int newcolor2 = oldPx[x+(y+1)*w];        r2 = (newcolor2 >> 16) & 0xFF;       g2 = (newcolor2 >> 8) & 0xFF;       b2 = (newcolor2 >> 0) & 0xFF;        int tr = (int) (2*Math.sqrt(((r-r1)*(r-r1)+(r-r2)*(r-r2))));       int tg = (int) (2*Math.sqrt(((g-g1)*(g-g1)+(g-g2)*(g-g2))));       int tb = (int) (2*Math.sqrt(((b-b1)*(b-b1)+(b-b2)*(b-b2))));        newPx[x+y*w] = (255 << 24)|(tr << 16)|(tg << 8)|(tb);     }   }   resultBitmap.setPixels(newPx, 0, w, 0, 0, w, h);   return resultBitmap; } 

對(duì)應(yīng)的效果圖如下:

原圖如下:

挺具有魔幻色彩的。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 康平县| 雷山县| 南江县| 西和县| 永康市| 庆城县| 读书| 桂平市| 蒙阴县| 萨迦县| 闸北区| 公安县| 绵阳市| 奎屯市| 曲沃县| 池州市| 九龙县| 岚皋县| 自贡市| 宿松县| 保山市| 巫溪县| 香河县| 黔南| 眉山市| 务川| 阳高县| 濉溪县| 沈丘县| 汕尾市| 黑河市| 岢岚县| 襄垣县| 手游| 邯郸市| 怀安县| 博白县| 盐边县| 剑阁县| 荔浦县| 万宁市|