1 | % * This code was used in the following articles:
|
---|
2 | % * [1] Learning 3-D Scene Structure from a Single Still Image,
|
---|
3 | % * Ashutosh Saxena, Min Sun, Andrew Y. Ng,
|
---|
4 | % * In ICCV workshop on 3D Representation for Recognition (3dRR-07), 2007.
|
---|
5 | % * (best paper)
|
---|
6 | % * [2] 3-D Reconstruction from Sparse Views using Monocular Vision,
|
---|
7 | % * Ashutosh Saxena, Min Sun, Andrew Y. Ng,
|
---|
8 | % * In ICCV workshop on Virtual Representations and Modeling
|
---|
9 | % * of Large-scale environments (VRML), 2007.
|
---|
10 | % * [3] 3-D Depth Reconstruction from a Single Still Image,
|
---|
11 | % * Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng.
|
---|
12 | % * International Journal of Computer Vision (IJCV), Aug 2007.
|
---|
13 | % * [6] Learning Depth from Single Monocular Images,
|
---|
14 | % * Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng.
|
---|
15 | % * In Neural Information Processing Systems (NIPS) 18, 2005.
|
---|
16 | % *
|
---|
17 | % * These articles are available at:
|
---|
18 | % * http://make3d.stanford.edu/publications
|
---|
19 | % *
|
---|
20 | % * We request that you cite the papers [1], [3] and [6] in any of
|
---|
21 | % * your reports that uses this code.
|
---|
22 | % * Further, if you use the code in image3dstiching/ (multiple image version),
|
---|
23 | % * then please cite [2].
|
---|
24 | % *
|
---|
25 | % * If you use the code in third_party/, then PLEASE CITE and follow the
|
---|
26 | % * LICENSE OF THE CORRESPONDING THIRD PARTY CODE.
|
---|
27 | % *
|
---|
28 | % * Finally, this code is for non-commercial use only. For further
|
---|
29 | % * information and to obtain a copy of the license, see
|
---|
30 | % *
|
---|
31 | % * http://make3d.stanford.edu/publications/code
|
---|
32 | % *
|
---|
33 | % * Also, the software distributed under the License is distributed on an
|
---|
34 | % * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
---|
35 | % * express or implied. See the License for the specific language governing
|
---|
36 | % * permissions and limitations under the License.
|
---|
37 | % *
|
---|
38 | % */
|
---|
39 | function cvx_sets = cvxhull_map(plane_pixels, grid_size) |
---|
40 | % load plane_pixels.mat |
---|
41 | % function get_convex_set(boundary_pixels) |
---|
42 | |
---|
43 | % boundary_pixels are clockwise |
---|
44 | % cvx_set = get_convex_set (boundary_pixels); |
---|
45 | |
---|
46 | % we get the minimum y value and start from it |
---|
47 | % as we move along the boundary we |
---|
48 | |
---|
49 | % does not do anything, but later on, if we want to change the superpixels into convex shapes. |
---|
50 | % Might solve the problem by rendering same parts twice in the wrl. |
---|
51 | |
---|
52 | % The way to call: cvx_sets = cvxhull_map(plane_pixels, 10); |
---|
53 | % for kk=1:length(cvx_sets) |
---|
54 | % boundary_pixels = [cvx_sets{kk}.x,cvx_sets{kk}.y]'; |
---|
55 | |
---|
56 | if ~exist('grid_size') |
---|
57 | grid_size=4; % grid size |
---|
58 | end |
---|
59 | |
---|
60 | gsize= grid_size; |
---|
61 | [m,n] = size(plane_pixels); |
---|
62 | |
---|
63 | clear cvx_sets; |
---|
64 | cvx_sets_count=0; |
---|
65 | |
---|
66 | hold on; |
---|
67 | for i=1:ceil((m-1)/gsize) |
---|
68 | for j=1:ceil((n-1)/gsize) |
---|
69 | patch = plane_pixels(gsize*(i-1)+1:min(gsize*i+1,m), gsize*(j-1)+1:min(gsize*j+1,n)); |
---|
70 | [I J]= find(patch>0); |
---|
71 | I= I+ gsize*(i-1); |
---|
72 | J= J+ gsize*(j-1); |
---|
73 | if (length(I)==0) continue; end; |
---|
74 | |
---|
75 | try |
---|
76 | cvxh = convhull(J,I); |
---|
77 | catch |
---|
78 | a=1; |
---|
79 | continue; |
---|
80 | end |
---|
81 | |
---|
82 | % plot (J(cvxh), I(cvxh)); |
---|
83 | cvx_sets_count= cvx_sets_count+1; |
---|
84 | cvx_sets{cvx_sets_count}.x = J(cvxh); |
---|
85 | cvx_sets{cvx_sets_count}.y = I(cvxh); |
---|
86 | end |
---|
87 | end |
---|
88 | hold off |
---|
89 | |
---|