Information Technology Reference
In-Depth Information
Figure 6.17.
Finding vertices with occlusion
occlusion.pl
calc_arr(V,V1,V2,V3) :-
img_arr(V,X,V2,Y), ltv_seq(V,X,V1), rtv_seq(V,Y,V3).
calc_arr(V,V1,V2,occ) :- img_tv(V3,_,V,_), calc_arr(V,V1,V2,V3).
calc_arr(V,occ,V2,V3) :- img_tv(V1,_,V,_), calc_arr(V,V1,V2,V3).
calc_lv(V,V1,V2) :-
img_lv(V,X,Y), ltv_seq(V,X,V1), rtv_seq(V,Y,V2).
calc_lv(V,V1,occ) :- img_tv(V2,_,V,_), calc_lv(V,V1,V2).
calc_lv(V,occ,V2) :- img_tv(V1,_,V,_), calc_lv(V,V1,V2).
calc_lv(occ,V1,V2) :- img_tv(_,_,V1,_), img_tv(_,_,V2,_), \+ V1=V2.
% ltv_seq(V,X,Y): V X ... Y via T-vertices left to right
ltv_seq(_,X,X).
ltv_seq(V,X,Y) :- img_tv(X,V,_,Z), ltv_seq(X,Z,Y).
% rtv_seq(V,X,Y): V X ... Y via T-vertices right to left
rtv_seq(_,X,X).
rtv_seq(V,X,Y) :- img_tv(X,Z,_,V), rtv_seq(X,Z,Y).
calc_lv(occ,V1,V2) :-
img_tv(_,_,V1,_), img_tv(_,_,V2,_), \+ V1=V2.
This is a very permissive rule, as there could be many T-vertices in an image. But
it does allow calc_lv(occ,2,4) to return success for this image, as desired. And
with all the other constraints in place for a cuboid, it will be sufficient. (If there were
additional image properties, one could be more selective.)
With all the pieces together for calc_arr and calc_lv , the occlusion program is
shown in figure 6.17. This will also handle the nonoccluded vertices as a special case.
If it is combined with the earlier definitions of cuboid and calc_fork from figure 6.15
and run on the image in figure 6.16, the result is
?- cuboid(A,B,C,D,E,F,G).
A = 6, B = 7, C = 2, D = occ, E = 4, F = 5, G=1;
A=9, B=15,C=12,D=13, E=14,F=8, G=11;
A=12,B=13,C=14,D=8, E=9, F=15,G=11;
A=14,B=8, C=9, D=15, E=12,F=13,G=11;
A=2, B=occ,C=4,D=5, E=6, F=7, G=1;
A = 4,
B = 5,
C = 6,
D = 7,
E = 2,
F = occ, G=1;
No
So the final program is able to tease apart the two objects and find all three views
of the occluding cuboid and all three views of the occluded cuboid.
Search WWH ::




Custom Search