1 Star 0 Fork 0

Harry/light-field-Processing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
demo.m 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
realcat 提交于 2021-01-25 23:33 . Update demo.m
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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/harry56/light-field-Processing.git
git@gitee.com:harry56/light-field-Processing.git
harry56
light-field-Processing
light-field-Processing
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385