Glow Filter發光濾鏡
Glow Filter發光濾鏡是一種讓圖像產生發光效果的濾鏡,它的實現算法如下:
1,對原圖P進行高斯模糊得到圖像A;
2,將P和A進行“疊加”圖層混合處理,公式如下:
Result(x,y) = ((basePixel(x,y) (x,y)?* basePixel(x,y)?/ 128):(255 - (255 - mixPixel(x,y)) * (255 - basePixel(x,y)) / 128));
注意:Result(x,y)屬于[0-255];
以上就是發光濾鏡的原理。
核心代碼如下:
~~~
private Bitmap GlowFilterProcess(Bitmap src)
{
Bitmap gaussBitmap = gf.Apply(src, 15);
Bitmap dst = new Bitmap(src);
int w = dst.Width;
int h = dst.Height;
BitmapData dstData = dst.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
BitmapData gaussData = gaussBitmap.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
byte* pGauss = (byte*)gaussData.Scan0;
byte* pDst = (byte*)dstData.Scan0;
int offset = dstData.Stride - w * 4;
int gray;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
gray = ((pDst[0] <= 128) ? (pGauss[0] * pDst[0] / 128) : (255 - (255 - pGauss[0]) * (255 - pDst[0]) / 128));
gray = Math.Min(255, Math.Max(0, gray));
pDst[0] = (byte)gray;
gray = ((pDst[1] <= 128) ? (pGauss[1] * pDst[1] / 128) : (255 - (255 - pGauss[1]) * (255 - pDst[1]) / 128));
gray = Math.Min(255, Math.Max(0, gray));
pDst[1] = (byte)gray;
gray = ((pDst[2] <= 128) ? (pGauss[2] * pDst[2] / 128) : (255 - (255 - pGauss[2]) * (255 - pDst[2]) / 128));
gray = Math.Min(255, Math.Max(0, gray));
pDst[2] = (byte)gray;
pDst[3] = (byte)255;
pGauss += 4;
pDst += 4;
}
pGauss += offset;
pDst += offset;
}
dst.UnlockBits(dstData);
gaussBitmap.UnlockBits(gaussData);
return dst;
}
~~~
效果圖如下:
[](http://www.zealpixel.com/data/attachment/portal/201507/27/181852caabbb57q5amxote.jpg)
原圖
[](http://www.zealpixel.com/data/attachment/portal/201507/27/181852idiuguhof2rtwquh.png)
Glow Filter效果圖
最后放上一個完整的 C# 程序Demo下載地址:[http://www.zealpixel.com/thread-65-1-1.html](http://www.zealpixel.com/thread-65-1-1.html)
- 前言
- 序言
- Brannan濾鏡
- 編碼基礎(Photoshop基礎變換的代碼實現)
- Toaster濾鏡
- Hudson濾鏡(Instagram)
- 暴雨濾鏡
- 大雪濾鏡
- 圖像濾鏡實現萬能方法研究
- 大霧效果濾鏡
- 連環畫濾鏡
- 暗調濾鏡
- 懷舊風格濾鏡
- (Nostalgla Filter)老照片濾鏡
- (Punch Filter)交叉沖印濾鏡
- (Lightleaks Filter)漏光濾鏡
- 漫畫濾鏡
- LOMO Filter
- Glow Filter發光濾鏡
- (Instagram)1977濾鏡
- (Sketch Filter)素描濾鏡
- 水彩畫濾鏡
- 圖像光照效果濾鏡
- Oilpaint油畫濾鏡
- Swirl濾鏡
- Wave濾鏡
- 球面(Spherize)濾鏡
- 擠壓(Pinch)濾鏡
- 旋轉模糊濾鏡
- 霓虹、浮雕、木刻濾鏡
- 圖像濾鏡暈影調節算法研究
- PS平均(濾鏡-模糊-平均)效果
- Photoshop實現Instagram Amaro濾鏡特效
- Photoshop實現Instagram之Nashville濾鏡
- Photoshop實現Instagram之Sierra濾鏡
- Photoshop實現Instagram之Mayfair濾鏡效果
- ZPhotoEngine超級算法庫
- 樂高像素拼圖特效
- 樂高像素拼圖特效濾鏡的代碼實現
- 保留細節的磨皮濾鏡之PS實現
- 保留細節的磨皮之C#程序實現
- 流行藝術風濾鏡特效PS實現
- PS圖層混合模式之明度模式