圖像濾鏡藝術---Hudson濾鏡(Instagram)

原文: 圖像濾鏡藝術---Hudson濾鏡(Instagram)

    今天給你們實現的是Instagram中的Hudson濾鏡,爲何介紹Instagram濾鏡,緣由很簡單,Instagram自己就是一個巨大的成功,迄今爲止,沒有哪一個軟件的濾鏡效果能夠超越它的。php

    Hudson濾鏡比較簡單,主要是一個模板的尋找,這個模板,我也是在網上找到的,若是單單用PS去實現這個模板效果,我以爲咱們是舍易取難,咱們追求的是最後的效果,而不是過程呵呵。css

    首先看下對比效果:html

   

                                    (a) Instagram  Hudson效果ide

   

                                                 (b) PS效果圖網站

    

                                                                    (c) C# 效果圖this

    按照原則,先介紹PS實現過程:spa

    1,打開原始圖像以及模板圖像,Instagram的目標效果圖像:.net

其中,圖層0爲原始圖像,圖層1爲模板圖像(模板圖像與psd文件一塊兒,我都會放到包裏供你們下載使用),另外的Hudson即Instagram中的效果圖像。orm

    2,選中圖層1,選擇「疊加」圖層混合模式,即獲得效果圖:htm

    而後,咱們介紹C#實現:

    按照PS的過程,C#代碼以下:

    

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace SpecialeffectDemo
{
    unsafe class HudsonFilter
    {
        public HudsonFilter(Bitmap src,Bitmap bg_a)
        {
            this.srcBitmap = src;
            this.map = bg_a;
        }
        private Bitmap srcBitmap = null;
        private Bitmap map = null;
        public Bitmap Apply()
        {
            if (srcBitmap != null)
            {
                Bitmap src = new Bitmap(srcBitmap);
                int w = srcBitmap.Width;
                int h = srcBitmap.Height;
                BitmapData srcData = src.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                BitmapData mapaData = map.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                byte* p = (byte*)srcData.Scan0;
                byte* pa = (byte*)mapaData.Scan0;
                int r = 0, g = 0, b = 0;
                for (int j = 0; j < h; j++)
                {
                    for (int i = 0; i < w; i++)
                    {
                        b = p[0];
                        g = p[1];
                        r = p[2];

                        b = SpecialEffectClass.ModeSuperpositionEffect(b, pa[0]);
                        g = SpecialEffectClass.ModeSuperpositionEffect(g, pa[1]);
                        r = SpecialEffectClass.ModeSuperpositionEffect(r, pa[2]);

                        p[0] = (byte)b;
                        p[1] = (byte)g;
                        p[2] = (byte)r;

                        p += 4;
                        pa += 4;
                    }
                    p += srcData.Stride - w * 4;
                    pa += mapaData.Stride - w * 4;
                }
                src.UnlockBits(srcData);
                map.UnlockBits(mapaData);
                return src;
            }
            else
            {
                return null;
            }
        }
       
    }
}


 

界面效果:

    最後給出代碼和PS實現過程的包,免費下載地址http://download.csdn.net/detail/trent1985/8177015

    以上就是Hudson這款濾鏡的實現過程,但願你們喜歡,有什麼問題能夠給我留言或者郵件:

郵箱dongtingyueh@163.com  QQ:1358009172

最後,分享一個專業的圖像處理網站(微像素),裏面有不少源代碼下載:
相關文章
相關標籤/搜索