Information Technology Reference
In-Depth Information
Figure 6.4.
The types of regions and their properties
regions.pl
% The five types of regions that can appear in an image
region(grass).
region(water).
region(pavement).
region(house). region(vehicle).
% small(X) holds when region X can be small in an image.
small(vehicle).
% regular(X) holds when region X can be regular in an image.
regular(pavement). regular(house). regular(vehicle).
% border(X,Y) holds when region X can border region Y.
border(X,Y) :- \+ bad_border(X,Y), \+ bad_border(Y,X).
% Unacceptable borders
bad_border(X,X).
bad_border(house,water).
bad_border(vehicle,X) :- \+ X=pavement.
% inside(X,Y) holds when region X can be surrounded by Y.
inside(X,Y) :- \+ bad_inside(X,Y).
% Unacceptable containment
bad_inside(X,X).
bad_inside(house,water).
bad_inside(vehicle,X) :- \+ X=pavement.
bad_inside(pavement,_).
Figure 6.5.
The image regions and their properties
Region R5 is small;
the others are large.
R1
Region R3 and R5 are regular;
R1 and R2 are irregular;
R4 could go either way.
R2
R3
Region R1 borders on R2;
R2 borders on R4.
R4
R5
Region R3 is inside R2;
R5 is inside R4.
This leads to the solution predicate in Prolog that appears in figure 6.6. Loading this
program together with the one in figure 6.4 produces this behavior:
 
Search WWH ::




Custom Search