-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdemo_joint_i2s_corres_main.m
70 lines (62 loc) · 2.55 KB
/
demo_joint_i2s_corres_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function [Corres_rs] = demo_joint_i2s_corres_main(...
Images, ImageCameras, Shapes, Adj_rs, Para)
% Thie function establishes dense correspondences among a collection of
% real images and natural images
% Input arguments:
% Images: input images, we assume images are of the same size, and
% please scale them properly
% ImageCameras: the associated camera configuration
% Shapes: input shapes
% Adj_rs: the sparse matrix that specifies the pairs of image-shapes
% that we want to compute dense correspondences
% Para: please refer to software document on how to change default
% parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output arguments:
% Corres_rr: the dense correspondences between pairs of images
% Corres_rs: the dense correspondences between images and shapes
%
Clusters = jis_view_clustering(ImageCameras,...
Para.viewDirectRadius_image_clustering);
%
fprintf('There are %d clusters.\n', length(Clusters));
%
for cId = 1:length(Clusters)
fprintf(' processing cluster %d...\n', cId);
Camera = Clusters{cId}.Camera;
imageIds = Clusters{cId}.imageIds;
%
numShapes = length(Shapes);
for id = 1 : length(imageIds)
Clusters{cId}.images{id} = Images{imageIds(id)}.im;
end
for id = 1 : numShapes
[meshPoints, renderImage] = co_ray_tracing(Shapes{id}, Camera);
Clusters{cId}.images{length(imageIds) + id} = renderImage;
Clusters{cId}.scans{id} = meshPoints;
end
% Compute correspondences among the rendered and the natural images
[Clusters{cId}.ffds, Clusters{cId}.hogDess] =...
dense_multi_image_corres(Clusters{cId}.images, Para);
end
numImages = length(Images);
imageClusIds = zeros(2, numImages);
for cId = 1 : length(Clusters)
imageClusIds(1, Clusters{cId}.imageIds) = cId;
imageClusIds(2, Clusters{cId}.imageIds) =...
1:length(Clusters{cId}.imageIds);
end
[imIds, shapeIds, vals] = find(Adj_rs);
Corres_rs = cell(1, length(imIds));
for id = 1:length(imIds)
Corres_rs{id}.imageId = imIds(id);
Corres_rs{id}.shapeId = shapeIds(id);
cId = imageClusIds(1, imIds(id));
im_cId = imageClusIds(2, imIds(id));
Corres_rs{id}.corres = establish_2d_3d_corres(...
Clusters{cId}.ffds{im_cId},...
Clusters{cId}.ffds{shapeIds(id)+length(Clusters{cId}.imageIds)},...
Clusters{cId}.scans{shapeIds(id)});
end