PS图像特效算法——镜像渐隐

这个特效的实现,可以先利用前面提到的渐变特效,做一个图像的渐变, 然后将原图与渐变图对称放置,将背景设置成黑色。


clc;
clear all;
close all;

Image=imread('4.jpg');
Image=double(Image)/255;
size_info=size(Image);  
height=size_info(1);  
width=size_info(2);  

Map=zeros(height, width);
for row_i=1:height
    Map(row_i, :)=row_i/height*0.75;
end
Img_1=Image;
for kk=1:3
      Img_1(:,:,kk)=Image(:,:,kk).*Map;
end
% % figure, imshow(Img_1);
Img_2=Img_1;
for ii=1:height
    Img_2(ii,:,:)=Img_1(height+1-ii,:,:);
end
% % figure, imshow(Img_2);

%% 缩放要注意,不要超出背景图的尺寸
small_1=imresize(Image, 0.45);
small_2=imresize(Img_2, 0.45);

Canvas=zeros(height, width, 3);
l_row=floor(height/2);
l_col=floor(width/4);

%% 将图像对称放置
Canvas(l_row:l_row+size(small_1,1)-1,l_col:l_col+...
                   size(small_1,2)-1,: )=small_2;    
Canvas(l_row-size(small_1,1):l_row-1,l_col:l_col+...
                   size(small_1,2)-1,: )=small_1;      
figure, imshow(Canvas);


原图:



效果图:






原文地址:https://www.cnblogs.com/mtcnn/p/9412712.html