代码拉取完成,页面将自动刷新
addpath(genpath(pwd));
%% Step 1: load LF data
% if you do not have LF data, please download before.
% uncomment either of the following two lines.
% load 'data/buddha2_LF_data.mat'
% [LF,LF_Remap,IM_Pinhole]=hdf2LF('data/Buddha2.h5');
img = imread('data/your_image.png'); % remap 2D image to 5D LF image
views=[4,4]; % [NOTE]: angular resolution of your image
LF = Remap2LF(img,views);
LF=mat2gray(LF);
ViewLightField(LF);
[vN,uN,h,w,ch]=size(LF);
%% Step 2: Horizontal EPI (fix v & y)
y_=490;
v_=4;
% EPI line in central-sub-view image
figure;
img=squeeze(LF(views(1)/2+1,views(2)/2+1,:,:,:));
imshow(img,'border','tight','initialmagnification','fit');
axis normal;
truesize;
line([1 w],[y_ y_],'color','r','linewidth',5);
set(gcf,'color',[1 1 1]);axis equal;
% saveas(gca,'buddha2_epi_line.jpg','jpg');
% draw EPI
figure;
imagesc(squeeze(LF(v_,:,y_,:,:)));
% set(gca,'position',[0.1 0.1,0.8 0.8])
set(gcf,'pos',[421,298,966,152])
set(gcf,'color',[1 1 1]);
set(gca,'xtick',[],'ytick',[]);
hold off
% saveas(gcf,'buddha2_epi.jpg');
%% Step 3: Vertical EPI (fix u & x)
x_=500;
u_=4;
% EPI line in central-sub-view image
figure;
img=squeeze(LF(views(1)/2+1,views(2)/2+1,:,:,:));
imshow(img,'border','tight','initialmagnification','fit');
axis normal
truesize
line([x_ x_],[h 1],'color','g','linewidth',5);
set(gcf,'color',[1 1 1]);axis equal
% draw EPI
figure;
imagesc(permute(squeeze(LF(:,u_,:,x_,:)),[2 1 3]));
% set(gca,'position',[0.1 0.1,0.8 0.8])
set(gcf,'pos',[582 -14 159 818])
set(gcf,'color',[1 1 1]);
set(gca,'xtick',[],'ytick',[]);
hold off
%saveas(gcf,'buddha2_epi.jpg');
%% Step 4: Show Angular Patches(AP)
% pos is the coordinates in central view
% result image is the corresponding AP in light field.
pos=[477 500];
ImshowAP(pos,views,LF)
pos=[600 265];
ImshowAP(pos,views,LF)
pos=[458 55];
ImshowAP(pos,views,LF)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。