source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/image3dstiching/Refinement/RedundentPlanePick_beforeJuly.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 5.8 KB
Line 
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% */
39function [model1 model2] = RedundentPlanePick(defaultPara, PointPix1, POriReprojM1, PointPix2, POriReprojM2, ImgInfo1, ImgInfo2, ScaleImg1, ScaleImg2)
40
41IND1 =  find( sum(PointPix1,1) ~= 0);
42IND2 =  find( sum(PointPix2,1) ~= 0);
43ScaleDepth1 = size(ImgInfo1.Model.Depth.FitDepth);
44ScaleDepth2 = size(ImgInfo2.Model.Depth.FitDepth);
45
46% find the index of the sup given the point and occlusion position in image pixels
47[Img1IndexTarget] = ProjPosi2Mask( ScaleImg1, ScaleDepth1, PointPix1(:,IND1));
48[Img2IndexField] = ProjPosi2Mask( ScaleImg2, ScaleDepth2, POriReprojM1(:,IND1));
49    % clean Target or Field map to sky (SupExpand() ==0)
50    SkymaskTarget = ImgInfo1.Model.PlaneParaInfo.SupEpand(Img1IndexTarget) == 0;
51    SkymaskField = ImgInfo2.Model.PlaneParaInfo.SupEpand(Img2IndexField) == 0;
52    Img1IndexTarget(SkymaskTarget | SkymaskField) = [];
53    Img2IndexField(SkymaskTarget | SkymaskField) = [];   
54   
55[Img2IndexTarget] = ProjPosi2Mask( ScaleImg2, ScaleDepth2, PointPix2(:,IND2));
56[Img1IndexField] = ProjPosi2Mask( ScaleImg1, ScaleDepth1, POriReprojM2(:,IND2));
57 % clean Target or Field map to sky (SupExpand() ==0)
58    SkymaskTarget = ImgInfo2.Model.PlaneParaInfo.SupEpand(Img2IndexTarget) == 0;
59    SkymaskField = ImgInfo1.Model.PlaneParaInfo.SupEpand(Img1IndexField) == 0;
60    Img2IndexTarget(SkymaskTarget | SkymaskField) = [];
61    Img1IndexField(SkymaskTarget | SkymaskField) = [];
62
63
64% take out the Plane Parameter to check the orientation
65PlanePara1Target = ImgInfo1.Model.PlaneParaInfo.PlanePara(:,ImgInfo1.Model.PlaneParaInfo.Sup2Para(...
66                   ImgInfo1.Model.PlaneParaInfo.SupEpand(Img1IndexTarget)));
67PlanePara1Target = PlanePara1Target./repmat(sqrt( sum( PlanePara1Target.^2,1)), 3, 1);
68PlanePara1Field = ImgInfo2.Model.PlaneParaInfo.PlanePara(:,ImgInfo2.Model.PlaneParaInfo.Sup2Para(...
69                   ImgInfo2.Model.PlaneParaInfo.SupEpand(Img2IndexField)));
70PlanePara1Field = PlanePara1Field./repmat(sqrt( sum( PlanePara1Field.^2,1)), 3, 1);
71
72PlanePara2Target = ImgInfo2.Model.PlaneParaInfo.PlanePara(:,ImgInfo2.Model.PlaneParaInfo.Sup2Para(...
73                    ImgInfo2.Model.PlaneParaInfo.SupEpand(Img2IndexTarget)));
74PlanePara2Target = PlanePara2Target./repmat(sqrt( sum( PlanePara2Target.^2,1)), 3, 1);
75PlanePara2Field = ImgInfo1.Model.PlaneParaInfo.PlanePara(:,ImgInfo1.Model.PlaneParaInfo.Sup2Para(...
76                    ImgInfo1.Model.PlaneParaInfo.SupEpand(Img1IndexField)));
77PlanePara2Field = PlanePara2Field./repmat(sqrt( sum( PlanePara2Field.^2,1)), 3, 1);
78
79
80% Pick out the Plane has a bigger normalized PlanPrameter of the Z component
81Img1IndexTargetOutliers = abs(PlanePara1Target(3,:)) < abs(PlanePara1Field(3,:));
82Img2IndexFieldOutliers = ~Img1IndexTargetOutliers;
83Img2IndexTargetOutliers = abs(PlanePara2Target(3,:)) < abs(PlanePara2Field(3,:));
84Img1IndexFieldOutliers = ~Img2IndexTargetOutliers;
85
86
87% Modify the Sup to 0 so that it won't rendered
88tempSup = ImgInfo1.Model.PlaneParaInfo.SupOri;
89tempSup( Img1IndexTarget( Img1IndexTargetOutliers)) = 0;
90tempSup(:,end) = ImgInfo1.Model.PlaneParaInfo.SupOri(:,end);
91tempSup(end,:) = ImgInfo1.Model.PlaneParaInfo.SupOri(end,:);
92ImgInfo1.Model.PlaneParaInfo.SupOri = tempSup;
93
94tempSup = ImgInfo2.Model.PlaneParaInfo.SupOri;
95tempSup( Img2IndexField( Img2IndexFieldOutliers)) = 0;
96tempSup(:,end) = ImgInfo2.Model.PlaneParaInfo.SupOri(:,end);
97tempSup(end,:) = ImgInfo2.Model.PlaneParaInfo.SupOri(end,:);
98ImgInfo2.Model.PlaneParaInfo.SupOri = tempSup;
99
100tempSup = ImgInfo2.Model.PlaneParaInfo.SupOri;
101tempSup( Img2IndexTarget( Img2IndexTargetOutliers)) = 0;
102tempSup(:,end) = ImgInfo2.Model.PlaneParaInfo.SupOri(:,end);
103tempSup(end,:) = ImgInfo2.Model.PlaneParaInfo.SupOri(end,:);
104ImgInfo2.Model.PlaneParaInfo.SupOri = tempSup;
105
106tempSup = ImgInfo1.Model.PlaneParaInfo.SupOri;
107tempSup( Img1IndexField( Img1IndexFieldOutliers)) = 0;
108tempSup(:,end) = ImgInfo1.Model.PlaneParaInfo.SupOri(:,end);
109tempSup(end,:) = ImgInfo1.Model.PlaneParaInfo.SupOri(end,:);
110ImgInfo1.Model.PlaneParaInfo.SupOri = tempSup;
111
112
113% assign model1 and model2
114model1 = ImgInfo1.Model;
115model2 = ImgInfo2.Model;
116
117return;
118
Note: See TracBrowser for help on using the repository browser.