source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/LearningCode/Inference/OldVersion/GenStraightLineFlexibleStickMedSup.m @ 173

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

Added original make3d

File size: 20.2 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 [Sup, MedSup, RayProjImgCo, MovedPatchBook, HBrokeBook, VBrokeBook, StraightLineTable, OccluList] = ...
40          GenStraightLine(seglist,MedSup, Sup, RayProjImgCo, Depth, MovedPatchBook, HBrokeBook, VBrokeBook, Ox, Oy, a, b)
41
42% This function 1)clean the Sup at the boundary of lines
43% 2) Stick the Ray closest to the boundary
44% 3) find out the StraightLineTable to be used as constrain in MRF
45global GeneralDataFolder ScratchDataFolder LocalFolder ClusterExecutionDirectory...
46    ImgFolder VertYNuPatch VertYNuDepth HoriXNuPatch HoriXNuDepth a_default b_default Ox_default Oy_default...
47    Horizon_default filename batchSize NuRow_default SegVertYSize SegHoriXSize WeiBatchSize PopUpVertY PopUpHoriX taskName;
48
49
50% initalize parameters
51NuSeg = size(seglist,1);
52Htol =  15*(pi/180);
53Vtol =  15*(pi/180);
54Vert3DTol = 80*(pi/180);
55Hori3DTol = 80*(pi/180);
56SptialDiff = 5;
57slab = 0; % extend the Straight line prior to wider in a slab
58StraightLineTable = [];
59OccluList = [];
60hardMerge = false;
61debug = false;
62Regroup = true;
63YRayProjPosi = permute(RayProjImgCo(2,:,:),[2 3 1]); %[VertYNuDepth HoriXNuDepth]
64XRayProjPosi = permute(RayProjImgCo(1,:,:),[2 3 1]); %[VertYNuDepth HoriXNuDepth]
65
66% sort the seglist by the length of seg in decending order
67List = sortrows([norms((seglist(:,1:2)-seglist(:,3:4))')' (1:NuSeg)'],1);
68List = flipud(List);
69seglist = seglist( List(:,end),:);
70% arrange the seglist to have start point a smaller X
71Pointer = seglist(:,1) > seglist(:,3);
72temp = seglist(Pointer,1:2);
73seglist(Pointer,1:2) = seglist(Pointer,3:4);
74seglist(Pointer,3:4) = temp;
75seglistMed = seglist;
76seglist(:,1:2) = Matrix2ImgCo(SegHoriXSize, SegVertYSize, seglist(:,1:2));
77seglist(:,3:4) = Matrix2ImgCo(SegHoriXSize, SegVertYSize, seglist(:,3:4));
78seglist(:,1:2) = ImgCo2Matrix(HoriXNuDepth, VertYNuDepth, seglist(:,1:2)); % now in the resolution of HoriXNuDepth, VertYNuDepth
79seglist(:,3:4) = ImgCo2Matrix(HoriXNuDepth, VertYNuDepth, seglist(:,3:4));
80
81% Find Projection point from x grid and y grid (Ray Move with Y grid only)
82%DownRightFlag = 1;
83OrientFlag = '';
84for i = 1:NuSeg
85    % find the YProjXGrid
86    if seglist(i,1) ~=seglist(i,3)
87       XGrid = (floor(seglist(i,1)):ceil(seglist(i,3)))';% interger Extend to make sure no rendering across line
88       XGridMed = Matrix2ImgCo(HoriXNuDepth, VertYNuDepth, [XGrid ones(size(XGrid,1),1)]);
89       XGridMed = ImgCo2Matrix( SegHoriXSize, SegVertYSize, XGridMed);
90       XGridMed(:,2) = [];
91    else
92       XGrid = [];
93       XGridMed = [];
94    end
95    if ~isempty(XGrid)
96       YProjXGridMed = LineProj(seglistMed(i,:),XGridMed,[]);% real number
97    else
98       YProjXGridMed = sparse(0,1);
99    end
100    % check if YProjXGrid > VertYNuDepth or YProjXGrid < 0
101
102    if ~isempty(XGridMed)
103       OutOfRange = XGridMed >= SegHoriXSize | XGridMed <= 1; % use it to sample the new Sup, os must be within range
104       OutOfRange = OutOfRange | ( YProjXGridMed >= SegVertYSize | YProjXGridMed <= 1); % same reason
105       YProjXGridMed(OutOfRange) = [];
106       XGridMed(OutOfRange) = [];
107       XGrid(OutOfRange) = [];
108    end
109
110    % find the YXProjYGrid
111    if seglist(i,2) > seglist(i,4)
112       YGrid = (floor(seglist(i,4)):ceil(seglist(i,2)))';% interger Extend to make sure no rendering across line
113    elseif seglist(i,2) < seglist(i,4)
114       YGrid = (floor(seglist(i,2)):ceil(seglist(i,4)))';% interger Extend to make sure no rendering across line
115    else
116       YGrid = [];
117       YGridMed = [];
118    end
119    if ~isempty(YGrid)
120       YGridMed = Matrix2ImgCo(HoriXNuDepth, VertYNuDepth, [ones(size(YGrid,1),1) YGrid]);
121       YGridMed = ImgCo2Matrix( SegHoriXSize, SegVertYSize, YGridMed);
122       YGridMed(:,1) = [];
123    end
124    if ~isempty(YGridMed)
125       XProjYGridMed = LineProj(seglistMed(i,:),[], YGridMed);% real number
126    else
127       XProjYGridMed = sparse(0,1);
128    end
129    % check if XProjYGrid > HoriXNuDepth or XProjYGrid < 0
130    if ~isempty(YGridMed)
131       OutOfRange = YGridMed >= SegVertYSize | YGridMed < 1; % use it to sample the new Sup, os must be within range
132       OutOfRange = OutOfRange | (XProjYGridMed > SegHoriXSize | XProjYGridMed < 1); % same reason
133       XProjYGridMed(OutOfRange) = [];
134       YGridMed(OutOfRange) = [];
135       YGrid(OutOfRange) = [];
136    end
137
138    % find Point in two side
139    if ~isempty(XGrid)
140        mask = YRayProjPosi(:,XGrid) < repmat(YProjXGridMed',[size(YRayProjPosi,1) 1]);
141        [YProjXGridMed_U YSub_U] = max(YRayProjPosi(:,XGrid).*mask,[],1);
142        YProjXGridMed_U =YProjXGridMed_U';
143        YSub_U = YSub_U';
144        mask = YRayProjPosi(:,XGrid) >= repmat(YProjXGridMed',[size(YRayProjPosi,1) 1]);
145        mask = double(mask);
146        mask(~mask) = Inf;
147        [YProjXGridMed_D YSub_D] = min(YRayProjPosi(:,XGrid).*mask,[],1);
148        YProjXGridMed_D = YProjXGridMed_D';
149        YSub_D = YSub_D';
150        % make sure YSub_D > YSub_U
151        mask = YSub_D <= YSub_U;
152        YProjXGridMed_D(mask) = [];
153        YProjXGridMed_U(mask) = [];
154        YSub_U(mask) = [];
155        YSub_D(mask) = [];
156        XGrid(mask) = [];
157        XGridMed(mask) = [];
158        YProjXGridMed(mask) = [];
159    end
160    if ~isempty(YGrid)
161        mask = XRayProjPosi(YGrid,:) < repmat(XProjYGridMed,[1 size(XRayProjPosi,2) ]);
162        [XProjYGridMed_L XSub_L] = max(XRayProjPosi(YGrid,:).*mask,[],2);
163        mask = XRayProjPosi(YGrid,:) >= repmat(XProjYGridMed,[1 size(XRayProjPosi,2) ]);
164        mask = double(mask);
165        mask(~mask) = Inf;
166        [XProjYGridMed_R XSub_R] = min(XRayProjPosi(YGrid,:).*mask,[],2);
167        % make sure XSub_R > XSub_L
168        mask = XSub_R <= XSub_L;
169        XProjYGridMed_R(mask) = [];
170        XProjYGridMed_L(mask) = [];
171        XSub_L(mask) = [];
172        XSub_R(mask) = [];
173        YGrid(mask) = [];
174        YGridMed(mask) = [];
175        XProjYGridMed(mask) = [];
176    end
177
178    % Stick Ray to segline boundary moving in X dorection only
179    % check MovedPatchBook before move
180    MovedPatchBookUpdate = MovedPatchBook;
181    if ~isempty(XGrid) % move Y derection and check if broke found
182       index = sub2ind([ VertYNuDepth HoriXNuDepth ],YSub_U, XGrid);
183       [cU,kU] = setdiff(index,MovedPatchBook);
184       if ~isempty(cU) % move only is not moved before
185%           if any(YProjXGridMed(kU) < YRayProjPosi( max(cU-1,1))) || ...
186%              any(YProjXGridMed(kU) > YRayProjPosi( min(cU+1,VertYNuDepth*HoriXNuDepth)))
187%              disp('error CU');
188%              return;
189%           end
190          MovedPatchBookUpdate = [MovedPatchBookUpdate; cU];
191          YRayProjPosi( cU) = YProjXGridMed(kU);
192          classifiedU = LineProj(seglistMed(i,:),XGridMed(1), YProjXGridMed_U(1));
193          if LineProj(seglistMed(i,:),floor(XRayProjPosi(cU)), floor(YRayProjPosi(cU))) == classifiedU
194             Sup(cU) = MedSup(sub2ind([SegVertYSize SegHoriXSize],floor(YRayProjPosi(cU)),floor(XRayProjPosi(cU))));
195          else
196             Sup(cU) = MedSup(sub2ind([SegVertYSize SegHoriXSize],floor(YRayProjPosi(cU)),ceil(XRayProjPosi(cU))));
197          end
198          if classifiedU == 1
199             StraightLine{1} = setdiff(Sup(cU)',0);
200          else
201             StraightLine{2} = setdiff(Sup(cU)',0);
202          end
203       end
204       index = sub2ind([ VertYNuDepth HoriXNuDepth ],YSub_D, XGrid);
205       [cD,kD] = setdiff(index,MovedPatchBook);
206       if ~isempty(cD) % move only is not moved before
207%           if any(YProjXGridMed(kD) < YRayProjPosi( max(cD-1,1))) || ...
208%              any(YProjXGridMed(kD) > YRayProjPosi( min(cD+1,VertYNuDepth*HoriXNuDepth)))
209%              disp('error CD');
210%              return;
211%           end
212          MovedPatchBookUpdate = [MovedPatchBookUpdate; cD];
213          YRayProjPosi( cD) = YProjXGridMed(kD);
214          classifiedD = LineProj(seglistMed(i,:),XGridMed(1), YProjXGridMed_D(1));
215          if LineProj(seglistMed(i,:),floor(XRayProjPosi(cD)), ceil(YRayProjPosi(cD))) == classifiedD
216             Sup(cD) = MedSup(sub2ind([SegVertYSize SegHoriXSize],ceil(YRayProjPosi(cD)),floor(XRayProjPosi(cD))));
217          else
218             Sup(cD) = MedSup(sub2ind([SegVertYSize SegHoriXSize],ceil(YRayProjPosi(cD)),ceil(XRayProjPosi(cD))));
219          end
220          if classifiedD == 1
221             StraightLine{1} = setdiff(Sup(cD)',0);
222          else
223             StraightLine{2} = setdiff(Sup(cD)',0);
224          end
225       end
226       % detect broken for rendering purpose
227       VBrokeBook( index(intersect(kU,kD))) = 1;
228      StraightLine{1} = unique(StraightLine{1});
229      StraightLine{2} = unique(StraightLine{2});
230      StraightLineTable = [StraightLineTable; (StraightLine)];
231       
232    end
233    if ~isempty(YGrid)
234       index = sub2ind([ VertYNuDepth HoriXNuDepth ],YGrid, XSub_L);
235       [cL,kL] = setdiff(index,MovedPatchBook);
236       [cLUpdate,kLUpdate] = setdiff(index,MovedPatchBookUpdate);
237       if ~isempty(cLUpdate) % move only is not moved before
238%           if any(XProjYGridMed(kLUpdate) < XRayProjPosi( max(cLUpdate-VertYNuDepth,1))) || ...
239%              any(XProjYGridMed(kLUpdate) > XRayProjPosi( min(cLUpdate+VertYNuDepth,VertYNuDepth*HoriXNuDepth)))
240%              disp('error CL');
241%              return;
242%           end
243          MovedPatchBookUpdate = [MovedPatchBookUpdate; cLUpdate];
244          XRayProjPosi( cLUpdate) = XProjYGridMed(kLUpdate);   
245          classifiedL = LineProj(seglistMed(i,:),XProjYGridMed_L(1), YGridMed(1));
246          if LineProj(seglistMed(i,:),floor(XRayProjPosi(cL)), floor(YRayProjPosi(cL))) == classifiedL
247             Sup(cL) = MedSup(sub2ind([SegVertYSize SegHoriXSize],floor(YRayProjPosi(cL)),floor(XRayProjPosi(cL))));
248          else
249             Sup(cL) = MedSup(sub2ind([SegVertYSize SegHoriXSize],ceil(YRayProjPosi(cL)),floor(XRayProjPosi(cL))));
250          end
251          if classifiedL == 1
252             StraightLine{1} = Sup(cL)';
253          else
254             StraightLine{2} = Sup(cL)';
255          end
256       end
257       index = sub2ind([ VertYNuDepth HoriXNuDepth ],YGrid, XSub_R);
258       [cR,kR] = setdiff(index,MovedPatchBook);
259       [cRUpdate,kRUpdate] = setdiff(index,MovedPatchBookUpdate);
260       if ~isempty(cRUpdate) % move only is not moved before
261%           if any(XProjYGridMed(kRUpdate) < XRayProjPosi( max(cRUpdate-VertYNuDepth,1))) || ...
262%              any(XProjYGridMed(kRUpdate) > XRayProjPosi( min(cRUpdate+VertYNuDepth,VertYNuDepth*HoriXNuDepth)))
263%              disp('error CR');
264%              return;
265%           end
266          MovedPatchBookUpdate = [MovedPatchBookUpdate; cRUpdate];
267          XRayProjPosi( cRUpdate) = XProjYGridMed(kRUpdate);
268          classifiedR = LineProj(seglistMed(i,:),XProjYGridMed_R(1), YGridMed(1));
269          if LineProj(seglistMed(i,:),ceil(XRayProjPosi(cR)), floor(YRayProjPosi(cR))) == classifiedR
270             Sup(cR) = MedSup(sub2ind([SegVertYSize SegHoriXSize],floor(YRayProjPosi(cR)),ceil(XRayProjPosi(cR))));
271          else
272             Sup(cR) = MedSup(sub2ind([SegVertYSize SegHoriXSize],ceil(YRayProjPosi(cR)),ceil(XRayProjPosi(cR))));
273          end
274          if classifiedR == 1
275             StraightLine{1} = Sup(cR)';
276          else
277             StraightLine{2} = Sup(cR)';
278          end
279       end
280       % detect broken for rendering purpose
281       % Hori is much tricky, most make sure end point double stick and
282       % if the Vert Stick corresponding to the side hori stick
283       HBrokeBook( index(intersect(kL,kR))) = 1;
284    end
285    MovedPatchBook = MovedPatchBookUpdate;
286% end of sticking ray and broking rendering point=========================================================
287% Start cleaning the MedSup
288    % define group in two side
289    if seglistMed(i,1) ~= seglistMed(i,3)
290       XGridMedDense = (ceil(seglistMed(i,1)):floor(seglistMed(i,3)))';
291    else
292       XGridMedDense = [];
293    end
294    if ~isempty(XGridMedDense)
295       YProjXGridMedDense = LineProj(seglistMed(i,:),XGridMedDense,[]);% real number
296    else
297       YProjXGridMedDense = sparse(0,1);
298    end
299    % check if YProjXGrid > VertYNuDepth or YProjXGrid < 0
300
301    if ~isempty(XGridMedDense)
302       OutOfRange = XGridMedDense >= SegHoriXSize+0.5 | XGridMedDense <= 0.5;
303       OutOfRange = OutOfRange | (YProjXGridMedDense >= SegVertYSize+0.5 | YProjXGridMedDense <= 0.5);
304       YProjXGridMedDense(OutOfRange) = [];
305       XGridMedDense(OutOfRange) = [];
306    end
307
308    % find the YXProjYGrid
309    if seglistMed(i,2) > seglistMed(i,4)
310       YGridMedDense = (ceil(seglistMed(i,4)):floor(seglistMed(i,2)))';% interger Extend to make sure no rendering across line
311    elseif seglistMed(i,2) < seglistMed(i,4)
312       YGridMedDense = (ceil(seglistMed(i,2)):floor(seglistMed(i,4)))';% interger Extend to make sure no rendering across line
313    else
314       YGridMedDense = [];
315    end
316    if ~isempty(YGridMedDense)
317       XProjYGridMedDense = LineProj(seglistMed(i,:),[], YGridMedDense);% real number
318    else
319       XProjYGridMedDense = sparse(0,1);
320    end
321    % check if XProjYGrid > HoriXNuDepth or XProjYGrid < 0
322    if ~isempty(YGridMedDense)
323       OutOfRange = YGridMedDense >= SegVertYSize+0.5 | YGridMedDense < 0.5;
324       OutOfRange = OutOfRange | (XProjYGridMedDense > SegHoriXSize+0.5 | XProjYGridMedDense < 0.5);
325       XProjYGridMedDense(OutOfRange) = [];
326       YGridMedDense(OutOfRange) = [];
327    end
328
329    group1 = [];
330    group2 = [];
331    group1Slab = [];
332    group2Slab = [];
333       if ~isempty(XGridMedDense)
334          if all(LineProj(seglistMed(i,:),XGridMedDense, floor(YProjXGridMedDense)) == 1)
335          group1 = [ group1; sub2ind([ SegVertYSize SegHoriXSize ], floor(YProjXGridMedDense), XGridMedDense)]; %side 1
336          group1Slab = group1(:,ones(slab,1)) + ones(size(group1,1),1)*[-1:-1:-slab];
337          group1Slab = group1Slab(:);
338          group2 = [ group2; sub2ind([ SegVertYSize SegHoriXSize ], ceil(YProjXGridMedDense), XGridMedDense)]; % side 0
339          group2Slab = group2(:,ones(slab,1)) + ones(size(group2,1),1)*[1:1:slab];
340          group2Slab = group2Slab(:);
341%          disp('Not suprising')
342          elseif all(LineProj(seglistMed(i,:), XGridMedDense, ceil(YProjXGridMedDense)) == 1)
343          group1 = [ group1; sub2ind([ SegVertYSize SegHoriXSize ], ceil(YProjXGridMedDense), XGridMedDense)]; %side 1
344          group1Slab = group1(:,ones(slab,1)) + ones(size(group1,1),1)*[-1:-1:-slab];
345          group1Slab = group1Slab(:);
346          group2 = [ group2; sub2ind([ SegVertYSize SegHoriXSize ], floor(YProjXGridMedDense), XGridMedDense)]; % side 0
347          group2Slab = group2(:,ones(slab,1)) + ones(size(group2,1),1)*[1:1:slab];
348          group2Slab = group2Slab(:);
349%          disp('suprising');
350          else
351            disp('error in combining group1 2');
352%            return;
353          end
354       end
355       if ~isempty(YGridMedDense)
356          if all(LineProj(seglistMed(i,:),ceil(XProjYGridMedDense), YGridMedDense) == 1)
357             group1 = [ group1; sub2ind([ SegVertYSize SegHoriXSize ], YGridMedDense, ceil(XProjYGridMedDense))];
358             temp = group1(:,ones(slab,1)) + ones(size(group1,1),1)*[1:1:slab]*SegVertYSize;
359             group1Slab = [group1Slab; temp(:)];
360             group2 = [ group2; sub2ind([ SegVertYSize SegHoriXSize ], YGridMedDense, floor(XProjYGridMedDense))];
361             temp = group2(:,ones(slab,1)) + ones(size(group2,1),1)*[-1:-1:-slab]*SegVertYSize;
362             group2Slab = [group2Slab; temp(:)];
363          elseif all(LineProj(seglistMed(i,:),floor(XProjYGridMedDense), YGridMedDense) == 1)
364             group1 = [ group1; sub2ind([ SegVertYSize SegHoriXSize ], YGridMedDense, floor(XProjYGridMedDense))];
365             temp = group1(:,ones(slab,1)) + ones(size(group1,1),1)*[-1:-1:-slab]*SegVertYSize;
366             group1Slab = [group1Slab; temp(:)];
367             group2 = [ group2; sub2ind([ SegVertYSize SegHoriXSize ], YGridMedDense, ceil(XProjYGridMedDense))];
368             temp = group2(:,ones(slab,1)) + ones(size(group2,1),1)*[1:1:slab]*SegVertYSize;
369             group2Slab = [group2Slab; temp(:)];
370          else
371             disp('error in combining group1 2');
372%             return;
373          end
374       end
375    group1Slab(group1Slab <=0 | group1Slab > (SegVertYSize*SegHoriXSize)) = [];
376    group2Slab(group2Slab <=0 | group2Slab > (SegVertYSize*SegHoriXSize)) = [];
377    group1 = [group1 ; group1Slab];
378    group2 = [group2 ; group2Slab];
379%     if size(group1,1)<=3
380%        if debug
381%           disp('empty group1');
382%        end
383%        continue;
384%     end
385    % modify the Sup index according to the new boundary found
386 if Regroup
387    FuzzySupPoint = intersect( MedSup(group1), MedSup(group2));   
388    if debug
389       size(FuzzySupPoint)
390    end
391    for j = FuzzySupPoint'
392        if j == 439
393           disp('Merge')
394        end
395        DominateFlag = 0;
396        mask = MedSup == j;
397        [My Mx] = find(mask);
398        classified = LineProj(seglistMed(i,:),Mx, My);
399        if sum(classified == 1) > sum(classified == 0)
400           DominateFlag = 1;
401        end
402        if ~any(classified ~= DominateFlag)
403           if debug
404              j
405              i
406              sum(MedSup(group1) == j)
407              sum(MedSup(group2) == j)
408           end
409           disp('error in classified')
410           save([ScratchDataFolder '/data/FuzzyFlag.mat'],'-v6');
411%           return;
412        end
413        targetX = [Mx(classified ~= DominateFlag)];
414        targetY = [My(classified ~= DominateFlag)];
415        MedSup(sub2ind([SegVertYSize SegHoriXSize ], targetY, targetX)) = ...
416            regroup(MedSup, targetY, targetX, ~DominateFlag, seglistMed(i,:));
417    end
418  end
419% end of cleaning MedSup at the boundary ========================================================
420% ===============================================================================================
421      % detect occlusion
422      [y1 x1] = ind2sub([SegVertYSize SegHoriXSize],group1);
423      group1 = Matrix2ImgCo(SegVertYSize, SegHoriXSize, [x1 y1]);
424      group1 = round(ImgCo2Matrix(HoriXNuDepth, VertYNuDepth, group1));
425      group1 = unique(group1,'rows');
426      group1 = sub2ind([ VertYNuDepth HoriXNuDepth], max(min(group1(:,2),VertYNuDepth),1), max(min(group1(:,1),HoriXNuDepth),1)); 
427      [y2 x2] = ind2sub([SegVertYSize SegHoriXSize],group2);
428      group2 = Matrix2ImgCo(SegVertYSize, SegHoriXSize, [x2 y2]);
429      group2 = round(ImgCo2Matrix(HoriXNuDepth, VertYNuDepth, group2));
430      group2 = unique(group2,'rows');
431      group2 = sub2ind([ VertYNuDepth HoriXNuDepth], max(min(group2(:,2),VertYNuDepth),1), max(min(group2(:,1),HoriXNuDepth),1)); 
432      if abs(median(Depth(group1))- median(Depth(group2))) >= SptialDiff
433         [X,Y] = meshgrid(Sup(group1),Sup(group2));
434         OccluList = [OccluList; sort([X(:) Y(:)],2)];
435      end
436%   end
437end
438OccluList = unique(OccluList,'rows');
439RayProjImgCo = permute(cat(3, XRayProjPosi, YRayProjPosi), [3 1 2]);
440save([ScratchDataFolder '/data/Sup.mat'],'Sup','-v6');
441return;
Note: See TracBrowser for help on using the repository browser.