source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/LearningCode/Features/OldBatchVersion/findBoundaryFeaturesMore.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 FeaSupNeighList=findBoundaryFeaturesMore(Sup_low,Sup_medi,nList,seglist, FeaMax, slack)
40%tic
41%load ../debugFeat.mat
42global H2;
43FeaSize = size(H2,1)
44
45NuSup = setdiff(unique(Sup_low)',0);
46NuSup = sort(NuSup);
47
48[currMask1, xVec1, yVec1, currMask2, xVec2, yVec2]=creatingMasks(Sup_low,Sup_medi);
49% load /afs/cs/group/reconstruction3d/scratch/maskSup1.mat
50% load /afs/cs/group/reconstruction3d/scratch/maskSup2.mat
51
52mask = zeros(size(Sup_medi,1),size(Sup_medi,2));
53bMask = mask;
54bCurrNeighMask = mask;
55
56%nRows = size(mask,1);
57%nCols = size(mask,2);
58%newMask = zeros(nRows,nCols,2);
59%colCount = 1:nCols;
60%rowCount = (1:nRows)';
61%newMask(:,:,1) = repmat(colCount,nRows,1);
62%newMask(:,:,2) = repmat(rowCount,1,nCols);
63
64currNeighMask=zeros(size(Sup_medi,1),size(Sup_medi,2));
65xV=zeros(1,size(mask,2));
66yV=zeros(1,size(mask,1));
67FeaSupNeighList = zeros(size(NuSup,2),FeaSize);
68
69countSup=1;
70for i = NuSup
71    nListCurr=find(nList(:,1)==i);
72    posInNuSup=find(NuSup==i);
73    if (posInNuSup<=500)
74        mask = full(currMask1{posInNuSup});
75        xV=xVec1{posInNuSup};
76        yV=yVec1{posInNuSup};
77    else
78        mask = full(currMask2{posInNuSup-500});
79        xV=xVec2{posInNuSup-500};
80        yV=yVec2{posInNuSup-500};
81    end
82    %% find midpoint of this superpixel
83    %% Notice that the sum command sums the columns of a matrix
84    x(1)=findSupMid(xV);   
85    y(1)=findSupMid(yV);
86   
87   
88    for j=1:length(nListCurr)
89        neighNum=nList(nListCurr(j),2);
90        posInNuSup=find(NuSup==neighNum);
91        if (posInNuSup<=500)
92            currNeighMask = full(currMask1{posInNuSup});
93             xV=xVec1{posInNuSup};
94             yV=yVec1{posInNuSup};
95        else
96            currNeighMask = full(currMask2{posInNuSup-500});
97            xV=xVec2{posInNuSup-500};
98            yV=yVec2{posInNuSup-500};
99        end
100       
101        %% Now we find the mid-point of the neighbor superpixel
102       
103        x(2)=findSupMid(xV);
104        y(2)=findSupMid(yV);
105       
106        %iPos=find(FeaSupList(1,:)==i);
107        %jPos=find(FeaSupList(1,:)==neighNum);
108       
109        %Xi = FeaSupList(2:end,iPos);
110        %Xj = FeaSupList(2:end,jPos);
111       
112        %FeaSupNeighList(countSup,3:(3+(length(Xi))-1)) =abs(Xi-Xj)';
113       
114%         %% Now we calculate the features with just average over the
115%         %% boundary
116%         [xCen,yCen]=findIntersectionPoint(mask,currNeighMask,x(1:2),y(1:2),newMask);
117        xCen = mean(x);
118        yCen = mean(y);
119        R = [sqrt((xCen-x(1))^2+(yCen-y(1))^2);sqrt((x(2)-xCen)^2+(y(2)-yCen)^2)];
120        R=R-slack*R;
121       
122        bMask = findCloserPointsSquare(mask,xCen,yCen,R(1));
123        bCurrNeighMask = findCloserPointsSquare(currNeighMask,xCen,yCen,R(2));
124       
125%         bMask = findCloserPointsSquare(mask,xCen,yCen,R(1));
126%         bCurrNeighMask = findCloserPointsSquare(currNeighMask,xCen,yCen,R(2));
127%         
128        if ((sum(sum(bMask))==0)||(sum(sum(bCurrNeighMask))==0))
129            bXi = zeros(1,FeaSize);
130            bXj = zeros(1,FeaSize);
131        else
132            bXi = (mean(H2(:,logical(bMask))')./FeaMax(1,2:18)); %% Min change this to 18
133            bXj = (mean(H2(:,logical(bCurrNeighMask))')./FeaMax(1,2:18)); %% Min change this to 18
134        end       
135     
136        FeaSupNeighList(countSup,1:FeaSize) =abs(bXi-bXj);
137        %% Now we check if any of the lines intersects the current
138        %% super-pixel and its current neighbor
139        FeaSupNeighList(countSup,FeaSize+1)=checkIfALineCrosses(seglist,x,y);
140%         for k=1:size(seglist,1)
141%             x(3)=seglist(k,1);
142%             y(3)=seglist(k,2);
143%             x(4)=seglist(k,3);
144%             y(4)=seglist(k,4);
145%             if(lineSegIntersect(x,y))
146%                 bndry_features(countSup,3)=1;
147%                 break;
148%             end
149%         end
150
151%        FeaSupNeighList(countSup,(3+length(Xi)+length(bXi))) = bndry_features(countSup,3);               
152%         FeaSupNeighList(countSup,(3+length(Xi))) = bndry_features(countSup,3);               
153        countSup=countSup+1;
154    end
155end
156
157size(FeaSupNeighList)
Note: See TracBrowser for help on using the repository browser.