[37] | 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 [model1 model2] = RedundentPlanePick(defaultPara, PointPix1, POriReprojM1, PointPix2, POriReprojM2, ImgInfo1, ImgInfo2, ScaleImg1, ScaleImg2) |
---|
| 40 | |
---|
| 41 | IND1 = find( sum(PointPix1,1) ~= 0); |
---|
| 42 | IND2 = find( sum(PointPix2,1) ~= 0); |
---|
| 43 | ScaleDepth1 = size(ImgInfo1.Model.Depth.FitDepth); |
---|
| 44 | ScaleDepth2 = 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 |
---|
| 65 | PlanePara1Target = ImgInfo1.Model.PlaneParaInfo.PlanePara(:,ImgInfo1.Model.PlaneParaInfo.Sup2Para(... |
---|
| 66 | ImgInfo1.Model.PlaneParaInfo.SupEpand(Img1IndexTarget))); |
---|
| 67 | PlanePara1Target = PlanePara1Target./repmat(sqrt( sum( PlanePara1Target.^2,1)), 3, 1); |
---|
| 68 | PlanePara1Field = ImgInfo2.Model.PlaneParaInfo.PlanePara(:,ImgInfo2.Model.PlaneParaInfo.Sup2Para(... |
---|
| 69 | ImgInfo2.Model.PlaneParaInfo.SupEpand(Img2IndexField))); |
---|
| 70 | PlanePara1Field = PlanePara1Field./repmat(sqrt( sum( PlanePara1Field.^2,1)), 3, 1); |
---|
| 71 | |
---|
| 72 | PlanePara2Target = ImgInfo2.Model.PlaneParaInfo.PlanePara(:,ImgInfo2.Model.PlaneParaInfo.Sup2Para(... |
---|
| 73 | ImgInfo2.Model.PlaneParaInfo.SupEpand(Img2IndexTarget))); |
---|
| 74 | PlanePara2Target = PlanePara2Target./repmat(sqrt( sum( PlanePara2Target.^2,1)), 3, 1); |
---|
| 75 | PlanePara2Field = ImgInfo1.Model.PlaneParaInfo.PlanePara(:,ImgInfo1.Model.PlaneParaInfo.Sup2Para(... |
---|
| 76 | ImgInfo1.Model.PlaneParaInfo.SupEpand(Img1IndexField))); |
---|
| 77 | PlanePara2Field = 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 |
---|
| 81 | Img1IndexTargetOutliers = abs(PlanePara1Target(3,:)) < abs(PlanePara1Field(3,:)); |
---|
| 82 | Img2IndexFieldOutliers = ~Img1IndexTargetOutliers; |
---|
| 83 | Img2IndexTargetOutliers = abs(PlanePara2Target(3,:)) < abs(PlanePara2Field(3,:)); |
---|
| 84 | Img1IndexFieldOutliers = ~Img2IndexTargetOutliers; |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | % Modify the Sup to 0 so that it won't rendered |
---|
| 88 | tempSup = ImgInfo1.Model.PlaneParaInfo.SupOri; |
---|
| 89 | tempSup( Img1IndexTarget( Img1IndexTargetOutliers)) = 0; |
---|
| 90 | tempSup(:,end) = ImgInfo1.Model.PlaneParaInfo.SupOri(:,end); |
---|
| 91 | tempSup(end,:) = ImgInfo1.Model.PlaneParaInfo.SupOri(end,:); |
---|
| 92 | ImgInfo1.Model.PlaneParaInfo.SupOri = tempSup; |
---|
| 93 | |
---|
| 94 | tempSup = ImgInfo2.Model.PlaneParaInfo.SupOri; |
---|
| 95 | tempSup( Img2IndexField( Img2IndexFieldOutliers)) = 0; |
---|
| 96 | tempSup(:,end) = ImgInfo2.Model.PlaneParaInfo.SupOri(:,end); |
---|
| 97 | tempSup(end,:) = ImgInfo2.Model.PlaneParaInfo.SupOri(end,:); |
---|
| 98 | ImgInfo2.Model.PlaneParaInfo.SupOri = tempSup; |
---|
| 99 | |
---|
| 100 | tempSup = ImgInfo2.Model.PlaneParaInfo.SupOri; |
---|
| 101 | tempSup( Img2IndexTarget( Img2IndexTargetOutliers)) = 0; |
---|
| 102 | tempSup(:,end) = ImgInfo2.Model.PlaneParaInfo.SupOri(:,end); |
---|
| 103 | tempSup(end,:) = ImgInfo2.Model.PlaneParaInfo.SupOri(end,:); |
---|
| 104 | ImgInfo2.Model.PlaneParaInfo.SupOri = tempSup; |
---|
| 105 | |
---|
| 106 | tempSup = ImgInfo1.Model.PlaneParaInfo.SupOri; |
---|
| 107 | tempSup( Img1IndexField( Img1IndexFieldOutliers)) = 0; |
---|
| 108 | tempSup(:,end) = ImgInfo1.Model.PlaneParaInfo.SupOri(:,end); |
---|
| 109 | tempSup(end,:) = ImgInfo1.Model.PlaneParaInfo.SupOri(end,:); |
---|
| 110 | ImgInfo1.Model.PlaneParaInfo.SupOri = tempSup; |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | % assign model1 and model2 |
---|
| 114 | model1 = ImgInfo1.Model; |
---|
| 115 | model2 = ImgInfo2.Model; |
---|
| 116 | |
---|
| 117 | return; |
---|
| 118 | |
---|