-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
38 lines (30 loc) · 957 Bytes
/
main.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
% Lithophane-generator
% main.m
%
% © Jacob Peroutek, 2020
% All rights reserved.
clc;
clear;
tic;
addpath('generators');
addpath('utils');
%% Image loading and processing
% Load the image
fprintf('Loading image...\n');
img_data = imread('samples/Disney_Train_Photo.jpg');
% Convert to grayscale if necessary
if ndims(img_data) > 2
img_data = rgb2gray(img_data);
end % if
% Normalize to a value [0-1]
normalized_heightmap = fliplr(im2double(img_data)');
% Darker spots should be thicker, so we invert the heightmap
normalized_heightmap = 1 - normalized_heightmap;
% Could possibly go ahead and convert the normalized heightmap to a biased map
% See `utils/height_with_bias.m`
fprintf('Estimating %d faces...\n', estimate_face_count_flat(size(img_data)));
fprintf('Beginning mesh generation...\n');
% Need to come up with a way to select the correct generator
x = flat(normalized_heightmap);
create_stl_binary('lithophane.stl', 'lith', x);
toc