-
Notifications
You must be signed in to change notification settings - Fork 33
/
run_ps.m
47 lines (35 loc) · 1.07 KB
/
run_ps.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
% Photometric stereo
%
%Author: Xiuming Zhang (GitHub: xiumingzhang), National Univ. of Singapore
%
clear;
close all;
clc;
addpath(genpath('./psmImages/'));
IMAGE = 'horse';
% Read in mask
mask = tga_read_image([IMAGE '.mask.tga']);
mask = rgb2gray(mask);
%------------------------ Get light directions, L
fileID = fopen('lights.txt', 'r');
s = textscan(fileID, '%f %f %f', 'HeaderLines', 1, 'Delimiter', ' ');
fclose(fileID);
L = [s{1} s{2} s{3}];
%------------------------ Get images, I (same order as L)
I = cell(12, 1);
for idx = 1:size(I, 1)
im = tga_read_image([IMAGE '.' num2str(idx-1) '.tga']);
I{idx} = im;
end
%========================= SURFACE NORMALS =========================%
N = compute_surfNorm(I, L, mask);
% Visualization
imwrite(N, sprintf('./results/%s_norm1.png', IMAGE));
h = show_surfNorm(N, 4);
saveas(h, sprintf('./results/%s_norm2.png', IMAGE));
%========================= HEIGHT MAP =========================%
Z = compute_heightMap(N, mask);
% Visualization
figure;
imshow(uint8(Z));
imwrite(uint8(Z), sprintf('./results/%s_height.png', IMAGE));