PS 濾鏡——素描演算法(一)

來源:互聯網
上載者:User

標籤:photoshop   演算法   應用   

這個演算法結合高斯濾波和圖層混合中的顏色減淡模式實現。

可以參考相關部落格:

http://blog.csdn.net/wsfdl/article/details/7610634


本文增加了一點調色,使得最終的素描效果可以不只是黑白,可以呈現不同的底色。


% % % % % 將映像轉換成黑白顏色 
% % % % % 複製映像,並對複製後的映像反相
% % % % % 將複製後的映像做高斯模糊 
% % % % % 將模糊後的映像與原映像以顏色減淡模式混合
% % % % % 設定一個底色層
% % % % % 做素描 

clc;
clear all;
addpath(‘E:\PhotoShop Algortihm\Image Processing\PS Algorithm‘);
Image=imread(‘9.jpg‘);
Image=double(Image)/255;

    I=(Image(:,:,1) + Image(:,:,2) + Image(:,:,3))/3;
    I_invert=1-I;
    F_size=20;
    F_gaussian = fspecial(‘gaussian‘,F_size,F_size/6);  
    I_gaussian = imfilter(I_invert,F_gaussian,‘conv‘); 
   
    delta=0.001;
    I_Dodge=(I+delta)./(1-I_gaussian+delta);
    
    Max_value=max(I_Dodge(:));
    [row, col]=size(I);
    Threshold=0.95;
    for i=1:row
        for j=1:col
            if(I_Dodge(i,j)>Threshold)
                I_Dodge(i,j)=Threshold+I_Dodge(i,j)/Max_value*(1-Threshold);
            end
        end
    end
               
    Image_Dodge(:,:,1)=I_Dodge;
    Image_Dodge(:,:,2)=I_Dodge;
    Image_Dodge(:,:,3)=I_Dodge;
    %%% figure, imshow(Image_Dodge);
    
    Base_layer=Image_Dodge;
    Base_layer(:,:,1)=210/255;
    Base_layer(:,:,2)=225/255;
    Base_layer(:,:,3)=105/255;
    
    alpha=0.7;
    Image1=alpha*Image_Dodge+(1-alpha)*Base_layer;
    R=Image1(:,:,1);
    G=Image1(:,:,2);
    B=Image1(:,:,3);
    %%% figure, imshow(Image1);
    
    Image3=Image_Dodge.*Image1;
    figure, imshow(Image3);
    
   
   
    原圖




PS 濾鏡——素描演算法(一)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.