图像滤镜艺术---Glow Filter发光滤镜
来源:互联网 发布:整人软件 编辑:程序博客网 时间:2024/05/17 04:46
Glow Filter发光滤镜
Glow Filter发光滤镜是一种让图像产生发光效果的滤镜,它的实现算法如下:
1,对原图P进行高斯模糊得到图像A;
2,将P和A进行“叠加”图层混合处理,公式如下:
Result(x,y) = ((basePixel(x,y) <= 128) ? (mixPixel(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;
}
效果图如下:
原图
Glow Filter效果图
最后放上一个完整的 C# 程序Demo下载地址:http://www.zealpixel.com/thread-65-1-1.html
0 0
- 图像滤镜艺术---Glow Filter发光滤镜
- 图像特效---Glow Filter发光滤镜
- 图像滤镜艺术---(Lightleaks Filter)漏光滤镜
- 图像滤镜艺术---(Sketch Filter)素描滤镜
- 图像滤镜艺术---LOMO Filter
- 图像滤镜艺术---(Nostalgla Filter)老照片滤镜
- 图像滤镜艺术---(Punch Filter)交叉冲印滤镜
- Glow滤镜
- 图像滤镜艺术----Brannan滤镜
- 图像滤镜艺术--Toaster滤镜
- 图像滤镜艺术--暴雨滤镜
- 图像滤镜艺术--大雪滤镜
- 图像滤镜艺术---连环画滤镜
- 图像滤镜艺术---漫画滤镜
- 图像滤镜艺术---水彩画滤镜
- 图像滤镜艺术---Swirl滤镜
- 图像滤镜艺术---Wave滤镜
- 图像滤镜艺术----Brannan滤镜
- call by value 和call by reference
- 第一章 Xen与kvm
- hibnate 测试注意点
- getContentLength=-1
- 霓歌即时通讯中的相关专利整理(十)
- 图像滤镜艺术---Glow Filter发光滤镜
- 完数 1406 (打表)
- Intel 80X86寄存器分类介绍
- doGet和doPost的区别
- TranslateAnimation的使用说明!
- Delphi XE3,C++ Builder XE3,RAD Studio XE3 v17.0.4770.56661(With Update 2) 官方下载激活
- hdu-5029
- MySQL 批量插入数据优化
- The difference between LayoutInflater.inflate and findViewById