在一幅摄影作品中,背景虚化可以很好地烘托主体,但是对于一些摄影爱好者来说,大光圈太贵;长焦镜头使用时限制太多;手中相机功能太低……虽条件不足,但又很想拍出主体突出、背景虚化的照片,这时候该怎么办呢?接下来本文简要介绍背景虚化的步骤。
% Input photograph
I = imread(‘pencils.png‘);
I = im2double(I);
IR = I(:,:,1);
IG = I(:,:,2);
IB = I(:,:,3);
% Joint image
J = imread(‘pencils_joint_depth.png‘);
J = im2double(J);
BW = im2bw(J,0.5);
% Depth-of-field Examples
sigma_s = 10;
sigma_r = 0.2;
% Edges superimposed.
F_nc = NC(I, sigma_s, sigma_r,3,J);
% Composition
Out = F_nc;
OutR = Out(:,:,1);
OutG = Out(:,:,2);
OutB = Out(:,:,3);
OutR(BW) = IR(BW);
OutG(BW) = IG(BW);
OutB(BW) = IB(BW);
Out = cat(3,OutR,OutG,OutB);
% Show results.
figure, imshow(I); title(‘Input photograph‘);
figure, imshow(Out); title(‘Filtered photograph‘);
http://www.g-photography.net/old/teach/news_693.html?g4
http://www.alphamatting.com/
http://www.inf.ufrgs.br/~eslgastal/DomainTransform/
原文地址:http://blog.csdn.net/bluecol/article/details/45481395