原文:图像滤镜艺术---LOMO Filter

LOMO Filter

LOMO是一种概念,即强调感受、机缘,弱化摄影技巧,不确定性和随意性是LOMO最大特点。LOMO源于Lomography,LOMO相机,它原先是苏联的产物,由列宁格勒光学与机械联盟于1980年制造出品,是一台为了大众需求而制造的傻瓜相机。常见的lomo照片构图没有章法,色彩浓郁,焦点不实,曝光不准,晃动糊片也很普遍。
LOMO的风格多种多样,本文简单介绍一种风格。
具体算法实现如下:
1,原图A与原图使用“柔光”图层混合,得到图B,公式如下:
        private int ModeSmoothLight(int basePixel, int mixPixel)
        {
            int res = 0;
            res = mixPixel > 128 ? ((int)((float)basePixel + ((float)mixPixel + (float)mixPixel - 255.0f) * ((Math.Sqrt((float)basePixel / 255.0f)) * 255.0f - (float)basePixel) / 255.0f)) :
                  ((int)((float)basePixel + ((float)mixPixel + (float)mixPixel - 255.0f) * ((float)basePixel - (float)basePixel * (float)basePixel / 255.0f) / 255.0f));
            return Math.Min(255, Math.Max(0, res)); 
        }
2,B与一种自己设定的风格色(比如蓝色:R-200,G-37,B-11)进行“排除”图层混合,设定40%透明度,得到图C,具体公式如下:
        private int ModeExclude(int basePixel, int mixPixel)
        {
            int res = 0;
            res = (mixPixel + basePixel) - mixPixel * basePixel / 128;
            return Math.Min(255, Math.Max(0, res));
        }
3,选则一种暗角模板,与C进行“叠加”图层混合,得到最终的LOMO效果,当然,如果不喜欢暗角效果,此步骤可以忽略;
核心代码如下:
        private Bitmap LOMOFilterProcess(Bitmap src)
        {
            Bitmap srcBitmap = new Bitmap(src);
            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 srcData = srcBitmap.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            byte* pSrc = (byte*)srcData.Scan0;
            byte* pDst = (byte*)dstData.Scan0;
            int offset = dstData.Stride - w * 4;
            int r,g,b;
            for (int j = 0; j < h; j++)
            {
                for (int i = 0; i < w; i++)
                {
                    b = ModeSmoothLight(pSrc[0], pDst[0]);
                    g = ModeSmoothLight(pSrc[1], pDst[1]);
                    r = ModeSmoothLight(pSrc[2], pDst[2]);
                    b = ModeExclude(b, 80);
                    g = ModeExclude(g, 15);
                    r = ModeExclude(r, 5);
                    pDst[0] = (byte)b;
                    pDst[1] = (byte)g;
                    pDst[2] = (byte)r;
                    pDst[3] = (byte)255;
                    pSrc += 4;
                    pDst += 4;
                }
                pSrc += offset;
                pDst += offset;
            }
            dst.UnlockBits(dstData);
            srcBitmap.UnlockBits(srcData);
            return dst;
        }
效果图如下:

原图

LOMO Filter效果图

最后,放上一个完整C#程序DEMO的下载链接:http://www.zealpixel.com/thread-66-1-1.html

图像滤镜艺术---LOMO Filter的更多相关文章

  1. 图像滤镜艺术---(Sketch Filter)素描滤镜

    原文:图像滤镜艺术---(Sketch Filter)素描滤镜 (Sketch Filter)素描滤镜 素描滤镜的实现方法比较简单,这里我们直接写出算法过程如下: 1,对原图S进行去色命令得到灰度图A ...

  2. 图像滤镜艺术---Glow Filter发光滤镜

    原文:图像滤镜艺术---Glow Filter发光滤镜 Glow Filter发光滤镜 Glow Filter发光滤镜是一种让图像产生发光效果的滤镜,它的实现算法如下: 1,对原图P进行高斯模糊得到图 ...

  3. 图像滤镜艺术---(Nostalgla Filter)老照片滤镜

    原文:图像滤镜艺术---(Nostalgla Filter)老照片滤镜 (Nostalgla Filter)老照片滤镜 Nostalgla Filter主要是通过算法来模拟一种复古,陈旧的照片风格,以 ...

  4. 图像滤镜艺术---(Punch Filter)交叉冲印滤镜

    原文:图像滤镜艺术---(Punch Filter)交叉冲印滤镜 (Punch Filter)交叉冲印滤镜 本文介绍一种交叉冲印效果的代码实现,至于原理,不在累赘,直接看代码:  int f_TPun ...

  5. 图像滤镜艺术---(Lightleaks Filter)漏光滤镜

    原文:图像滤镜艺术---(Lightleaks Filter)漏光滤镜 (Lightleaks Filter)漏光滤镜 漏光拍摄其实就是一种摄影手法,最初是因为强烈光照导致相片交卷的过分曝光,最终在成 ...

  6. 图像滤镜艺术---ZPhotoEngine超级算法库

    原文:图像滤镜艺术---ZPhotoEngine超级算法库 一直以来,都有个想法,想要做一个属于自己的图像算法库,这个想法,在经过了几个月的努力之后,终于诞生了,这就是ZPhotoEngine算法库. ...

  7. 图像滤镜艺术---Wave滤镜

    原文:图像滤镜艺术---Wave滤镜 Wave Filter水波滤镜 水波滤镜是通过坐标变换来模拟水波效果,使图像呈现出水波的特效.这个滤镜有一个可调参数:水波的扭曲程度. 代码如下; //     ...

  8. 图像滤镜艺术---球面(Spherize)滤镜

    原文:图像滤镜艺术---球面(Spherize)滤镜 球面(Spherize)滤镜 球面滤镜是通过极坐标变换实现图像的球面特效. 代码如下:         //         ///        ...

  9. 图像滤镜艺术---挤压(Pinch)滤镜

    原文:图像滤镜艺术---挤压(Pinch)滤镜 Pinch滤镜 Pinch滤镜是通过坐标变换来实现以某个点(cenX,cenY)为中心,某个半径R内图像向其挤压变形的效果.实现这个滤镜的算法很多,主要 ...

随机推荐

  1. [Ramda] Filter an Array Based on Multiple Predicates with Ramda's allPass Function

    In this lesson, we'll filter a list of objects based on multiple conditions and we'll use Ramda's al ...

  2. 【codeforces 546C】Soldier and Cards

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 移动端iPhone系列适配问题的一些坑

    完成移动端的开发项目之后,发现谷歌自带的调试器似乎没有什么太大的作用,整天借同事的苹果手机测bug,尽管同事不厌其烦,但还是觉得这iPhone系列适配问题适配到想逃逃逃,好在项目已经顺利完成,测试通过 ...

  4. Thermal zone monitoring in an electronic device

    FIELD One embodiment of the invention relates to a closed loop thermal control process in a portable ...

  5. C 删除字符串1字符串2

    #include<stdio.h> #include<string.h> void main() { char s1[1000],s2[100],b[100]; int i,j ...

  6. 报错:javax.servlet.jsp.PageContext cannot be resolved to a type;javax.servlet.jsp.JspException cannot be resolved to a type

    Multiple annotations found at this line: - javax.servlet.jsp.PageContext cannot be resolved to a typ ...

  7. Windows下如何采用微软的Caffe配置Faster R-CNN

    前言 比较简单的一篇博客.https://github.com/microsoft/caffe 微软的Caffe以在Windows下编译简单而受到了很多人的喜爱(包括我),只用改改prop配置然后无脑 ...

  8. 矿Spring入门Demo

    第一步:输入Spring jar 包裹 Spring核心包(4个)  日志包(2个)  jdbc模板支持(1个)  spring-jdbc-3.2.0.RELEASE.jar  模板相关事务处理包(1 ...

  9. 北大SQL数据库视频课程笔记

    Jim Gray - Transaction processing: concepts and techniqueshttp://research.microsoft.com/~gray/ 事务概念 ...

  10. LaTex 加粗(加黑)的方式

    1. 基本 LaTeX技巧458:关于LaTeX数学字体加粗 $\mathbf $,会变为粗体,但也导致数学字母斜体形式的丢失: 使用 amsmath package 的 \boldmath 命令: ...