概述
今天给大家介绍一款大雪滤镜,可以使你夏天的照片瞬间幻化为大雪纷飞的场景哦!先看下效果图:
上面三张图像分别是(a)原始图像,(b)PS效果图,(c)C#代码效果图
这个大雪滤镜也比较简单,按照之前的步骤,我们依次介绍PS实现过程以及代码实现过程。
PS实现过程如下:
1,打开原始图像,复制图层a,新建图层mask,填充为黑色;
2,滤镜--杂色--添加杂色:
3,模糊--进一步模糊:
4,调整色阶:
5,高斯模糊,与a进行混合,选择混合图层—滤色模式:
6,原图调出冷色调:
这样就出来了大雪效果了 ,其实大家会发现,这个滤镜跟上一篇博客中的暴雨滤镜差不多,关键都是模板的制作,大家可以对比一下呵呵。
然后我们来介绍一下代码实现吧:
这里的模板,我已经放在了资源包里,大家可以直接拿来使用,如果大小不合适,那么自行变换一下即可。这样代码实现就可以简化为两个 步骤:
1,将原始图进行调色,调出一种冬天特有的清冷,也就是蓝色分量多一些 ;
2,将调整好的图像与模板进行“滤色”图层混合即可;
这里给出主要代码:
amespace SpecialeffectDemo
{
unsafe class SnowFilter
{
private Bitmap curBitmap = null;
private Bitmap snowMap = null;
public SnowFilter(Bitmap src,Bitmap map)
{
this.curBitmap = src;
this.snowMap = map;
}
public Bitmap Apply()
{
return RainFilterProcess();
}
private Bitmap RainFilterProcess()
{
Bitmap temp = ColdEffect(curBitmap);
return SpecialEffectClass.DoEffect(temp, snowMap, 0, (int)SpecialEffectClass.EffectMode.MODE_FILTERCOLOR);//滤色处理
}
private Bitmap ColdEffect(Bitmap srcBitmap)
{
Bitmap src = new Bitmap(srcBitmap);
int w = src.Width;
int h = src.Height;
int b = 0,g = 0,r = 0;
int[] mR = new int[] { 0, 0, 0, 1, 1, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 10, 10, 11, 13, 13, 14, 14, 15, 16, 16, 17, 18, 19, 20, 21, 21, 22, 22, 23, 24, 26, 25, 27, 27, 29, 29, 30, 31, 33, 32, 34, 34, 36, 36, 37, 38, 39, 39, 40, 41, 43, 42, 43, 45, 47, 47, 48, 49, 51, 51, 52, 53, 55, 56, 57, 57, 58, 58, 58, 59, 61, 62, 63, 63, 65, 65, 66, 67, 69, 70, 71, 71, 73, 73, 74, 75, 77, 78, 79, 79, 81, 81, 82, 83, 85, 86, 87, 87, 89, 89, 90, 91, 93, 94, 95, 95, 97, 97, 98, 99, 101, 103, 104, 103, 106, 106, 107, 108, 110, 111, 112, 112, 114, 114, 115, 116, 118, 119, 119, 120, 122, 122, 123, 124, 126, 127, 128, 128, 129, 129, 130, 132, 134, 137, 138, 138, 140, 140, 139, 140, 142, 145, 145, 145, 147, 147, 149, 151, 153, 154, 154, 154, 156, 156, 157, 158, 160, 163, 164, 162, 164, 164, 167, 167, 170, 172, 172, 172, 174, 174, 176, 176, 178, 180, 180, 180, 182, 182, 183, 185, 187, 190, 191, 191, 191, 191, 192, 195, 197, 199, 200, 200, 202, 201, 202, 203, 207, 206, 207, 209, 209, 211, 213, 213, 216, 217, 217, 217, 220, 220, 220, 221, 224, 226, 227, 227, 230, 230, 231, 232, 234, 235, 235, 237, 238, 238, 240, 241, 243, 243, 246, 246, 248, 248, 249, 250, 253, 254, 255, 255 };
int[] mG = new int[] { 2, 2, 4, 7, 10, 12, 13, 13, 15, 15, 18, 18, 21, 22, 23, 24, 26, 26, 27, 29, 31, 32, 34, 33, 36, 36, 37, 39, 40, 41, 42, 42, 46, 46, 47, 48, 50, 51, 53, 53, 55, 55, 56, 57, 59, 60, 62, 62, 64, 64, 65, 66, 67, 69, 70, 69, 73, 72, 73, 75, 77, 79, 80, 79, 81, 81, 82, 83, 85, 86, 87, 87, 90, 90, 90, 91, 93, 94, 95, 95, 97, 97, 98, 99, 101, 102, 103, 103, 105, 105, 106, 107, 109, 110, 111, 111, 113, 113, 114, 115, 117, 118, 119, 119, 121, 121, 122, 123, 125, 126, 127, 127, 128, 128, 130, 131, 133, 133, 134, 135, 136, 136, 137, 138, 140, 141, 142, 142, 144, 144, 145, 146, 148, 149, 149, 148, 150, 150, 151, 152, 154, 155, 156, 156, 159, 159, 160, 160, 162, 163, 164, 164, 166, 166, 167, 168, 170, 171, 171, 171, 173, 173, 175, 175, 177, 178, 180, 180, 180, 180, 181, 182, 184, 184, 185, 186, 188, 188, 188, 188, 191, 192, 193, 193, 195, 195, 196, 196, 198, 198, 200, 200, 202, 202, 203, 203, 205, 206, 207, 207, 209, 209, 210, 211, 213, 213, 214, 214, 216, 217, 216, 217, 219, 220, 221, 221, 223, 223, 225, 225, 226, 227, 229, 229, 230, 230, 230, 231, 233, 235, 236, 236, 236, 236, 237, 238, 240, 241, 241, 241, 244, 242, 244, 245, 247, 247, 248, 248, 250, 250, 251, 252, 253, 254, 255, 255 };
int[] mB = new int[] { 1, 1, 3, 7, 9, 11, 12, 12, 16, 16, 18, 18, 21, 22, 24, 25, 26, 26, 27, 29, 31, 32, 33, 33, 35, 35, 38, 40, 41, 42, 43, 43, 46, 46, 47, 48, 50, 50, 52, 52, 54, 54, 55, 56, 60, 61, 63, 63, 65, 65, 66, 67, 68, 69, 70, 70, 73, 72, 73, 75, 77, 78, 79, 79, 81, 81, 82, 83, 85, 86, 87, 87, 89, 89, 89, 90, 92, 93, 94, 94, 96, 96, 97, 98, 100, 101, 102, 102, 104, 104, 105, 106, 108, 109, 110, 110, 112, 112, 113, 114, 116, 117, 118, 118, 120, 120, 121, 122, 124, 125, 126, 126, 130, 130, 129, 130, 132, 133, 134, 134, 136, 136, 137, 138, 140, 141, 142, 142, 144, 144, 145, 146, 148, 149, 149, 149, 151, 151, 152, 153, 155, 156, 157, 157, 159, 159, 160, 161, 163, 164, 165, 165, 167, 167, 168, 169, 171, 172, 172, 172, 172, 172, 174, 175, 177, 178, 179, 179, 180, 180, 181, 182, 184, 185, 186, 186, 188, 188, 189, 189, 192, 193, 194, 194, 196, 196, 195, 195, 197, 198, 199, 199, 201, 201, 202, 203, 205, 206, 207, 207, 209, 209, 210, 211, 213, 214, 215, 215, 217, 217, 216, 217, 219, 220, 221, 221, 223, 223, 225, 225, 227, 228, 229, 229, 231, 231, 231, 232, 232, 234, 235, 235, 236, 236, 237, 238, 240, 241, 241, 242, 244, 243, 245, 246, 248, 248, 247, 247, 249, 249, 250, 251, 253, 254, 255, 255 };
BitmapData srcData = src.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
byte* p = (byte*)srcData.Scan0;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
b = p[0];
g = p[1];
r = p[2];
p[0] = (byte)mB[b];
p[1] = (byte)mG[g];
p[2] = (byte)mR[r];
p += 3;
}
p += srcData.Stride - w * 3;
}
src.UnlockBits(srcData);
return src;
}
}
}
记得,有什么问题联系我哦,本人邮箱dongtingyueh@163.com, QQ: 1358009172
最后,分享一个专业的图像处理网站(微像素),里面有很多源代码下载:
最后
以上就是传统项链为你收集整理的用php照片艺术化,图像滤镜艺术--大雪滤镜的全部内容,希望文章能够帮你解决用php照片艺术化,图像滤镜艺术--大雪滤镜所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复