-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.m~
56 lines (39 loc) · 1.36 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
close all
clear all
input_dir = 'medium-sample/';
file_ext = 'png';
files = dir([input_dir '*.' file_ext]);
%% Get set of images for each scene (each column is a scene)
[scenes, scene_sizes] = separate_scenes(input_dir, files);
scene_sizes
disp('Number of scenes:')
num_scenes = size(scenes, 2)
max_imgs_scene = size(scenes, 1);
%% Get image near center of each scene
images_to_col = [];
for i = 1:num_scenes
mid_file = scenes(ceil(scene_sizes(i)/2),i);
images_to_col = [images_to_col; mid_file];
end
%% List these scenes as ones that need to be colorized
%List of images to colorize
for file = images_to_col
fprintf('%s\n', file.name);
end
disp('Colorize the above images in an image editor them <file_name>_scr.png and store in root dir, then press ENTER')
pause
%% Colorize each image based on user scribbles, then apply to each scene
for i = 1:size(images_to_col,1)
img = images_to_col(i).name;
img_scr = [img(1:end-4) '_scr.png'];
% img = imread([input_dir img]);
% img_scr = imread(img_scr);
% Colorization by optimization
img_col = colorize_opt(input_dir, img, img_scr);
fprintf('Colorized by opt: %s to get %s', img, img_col);
% Colorization by example
for j = 1:scene_sizes(i)
targets{j} = [input_dir scenes(j,i).name];
end
results = colorize_ex(img_col, targets);
end