分享一下怎么把照片处理成梦幻柔光效果,希望大家喜欢。
过程比较简单,如下
Matlab版
function imDst = softglow(varargin)
% ==============================================
% Simulatethe softglow effect
%
% Paras:
% @im : input image ranging value from 0 to 255.
% @ks : kernel size,default 5.
% @level : adjust brightness value from -1 to 1, default 0.05.
%
%
% Example
% ==========
% I = imread(‘jiangkaitong.jpg‘);
% Out = softglow(I,10,0.05);
% figure,imshow(I);
% figure,imshow(Out);)
%
% Author: 风吹夏天
% Email:272793757@qq.com
[I,hsize,level] =parse_inputs(varargin{:});
h=fspecial(‘gaussian‘,[hsize hsize],100);
imBlur = double(imfilter(I,h));
imAdjust = double(adjust_brightness(I,level));
imDst = uint8(imAdjust + imBlur -imAdjust.*imBlur/255);
end
%--------------------------------------------------------------------
function out = adjust_brightness(im,level)
delta = level + 1;
lut = 1:1:255;
lut = uint8(lut*delta);
out = lut(im + 1);
end
%-------------------------------------------------------------------
function [I,hsize,level] = parse_inputs(varargin)
narginchk(1,3)
I = varargin{1};
validateattributes(I,{‘double‘,‘logical‘,‘uint8‘,‘uint16‘,‘int16‘,‘single‘},{},...
mfilename,‘Image‘,1);
if nargin == 1
hsize = 5;
level = 0.05;
elseif nargin == 3
hsize = varargin{2};
level = varargin{3};
else
error(message(‘images:im2double:invalidIndexedImage‘,‘single, or logical.‘));
end
end
http://xiangwangfeng.com/2011/02/28/%E5%9B%BE%E7%89%87%E7%BC%96%E8%BE%91%E4%B9%8B%E4%B8%80%E9%94%AE%E7%89%B9%E6%95%88/
http://www.cnblogs.com/Imageshop/p/3145216.html
作者 | 日期 | 联系方式 |
---|---|---|
风吹夏天 | 2015年5月22日 | 272793757@qq.com |
原文地址:http://blog.csdn.net/bluecol/article/details/45918569