You are on page 1of 15

AUTOMATIC FOCUSING SYSTEM

$ FILENAME: camera/af1.fil

$ Three inputs, three outputs, decision making


$ for Automatic Focusing System
$ INPUT(S): Left(Distance), Center(Distance), Right(Distance)
$ OUTPUT(S): Plau(sibility)_of_Left, Plau(sibility)_of_Center,
Plau(sibility)_of_Right

$ FIU HEADER

fiu tvfi (min max) *8;

$ DEFINITION OF INPUT VARIABLE(S)

invar Left "meter" : 1 () 100 [


Far (@10, 0, @40, 1, @100, 1),
Medium (@1, 0, @10, 1, @40, 0),
Near (@1, 1, @10, 0)
];

invar Center "meter" : 1 () 100 [


Far (@10, 0, @40, 1, @100, 1),
Medium (@1, 0, @10, 1, @40, 0),
Near (@1, 1, @10, 0)
];

invar Right "meter" : 1 () 100 [


Far (@10, 0, @40, 1, @100, 1),
Medium (@1, 0, @10, 1, @40, 0),
Near (@1, 1, @10, 0)
];

$ DEFINITION OF OUTPUT VARIABLE(S)

outvar Plau_of_Left "degree" : 0 () 1 * (


VeryHigh = 1.0,
High = 0.8,
Medium = 0.5,
Low = 0.3
);

outvar Plau_of_Center "degree" : 0 () 1 * (


VeryHigh = 1.0,
High = 0.8,
Medium = 0.5,
Low = 0.3
);

outvar Plau_of_Right "degree" : 0 () 1 * (


VeryHigh = 1.0,
High = 0.8,
Medium = 0.5,
Low = 0.3
);

$ RULES

R1 if Left is Near then Plau_of_Left is Medium;


R2 if Center is Near then Plau_of_Center is Medium;
R3 if Right is Near then Plau_of_Right is Medium;

R4 if Left is Near and Center is Near and Right is Near then


Plau_of_Center is High;
R5 if Left is Near and Center is Near then Plau_of_Left is Low;
R6 if Right is Near and Center is Near then Plau_of_Right is Low;

R7 if Left is Medium then Plau_of_Left is High;


R8 if Center is Medium then Plau_of_Center is High;
R9 if Right is Medium then Plau_of_Right is High;

R10 if Left is Medium and Center is Medium and Right is Medium


then Plau_of_Center is VeryHigh;
R11 if Left is Medium and Center is Medium then Plau_of_Left is
Low;
R12 if Right is Medium and Center is Medium then Plau_of_Right is
Low;

R13 if Left is Far then Plau_of_Left is Low;


R14 if Center is Far then Plau_of_Center is Low;
R15 if Right is Far then Plau_of_Right is Low;
R16 if Left is Far and Center is Far and Right is Far then
Plau_of_Center is High;

R17 if Left is Medium and Center is Far then Plau_of_Center is


Low;
R18 if Right is Medium and Center is Far then Plau_of_Center is
Low
end
AUTOMATIC FOCUSING SYSTEM: (Sistema de
Enfoque Automático)
Se determinará la distancia del objeto, usando tres medidas de
distancia para un sistema de enfoque de una cámara automática.

VARIABLES VARIABLES
DE ENTRADA DE SALIDA

LEFT (L) P_LEFT

CENTER (C) P_CENTER

RIGHT (R) P_RIGHT

LEFT: Universo de discurso [1 - 100]


Conjunto Difuso
FAR [10 100]
MEDIUM [1 40]
NEAR [1 10]

CENTER: Universo de discurso [1 - 100]


Conjunto Difuso
FAR [10 100]
MEDIUM [1 40]
NEAR [1 10]

RIGHT: Universo de discurso [1 - 100]


Conjunto Difuso
FAR [10 100]
MEDIUM [1 40]
NEAR [1 10]

VARIABLES DE ENTRADA:
μX (X)

LEFT (L)

Far
1 Near Medium

1 10 40 100 L

CENTER (C)
Near Far
Medium
1

1 40 100 C
10

RIGHT (R)
Near Far
Medium
1

1 40 100
10
R
VARIABLES DE SALIDA: (en singletons)

P_LEFT (PL)
μX (X)

Low Medium High Very_High


1

0
0.3 0.5 0.8 1 PL

P_CENTER (PC)

Low Medium High Very_High

0
0.3 0.5 0.8 1 PC

P_RIGHT (PR)
Low Medium High Very_High

0
0.3 0.5 0.8 1 PR
1. Fuzificación
Entrada Numérica:
0.22 Near
PL 0.78 Medium
LEFT = 8
PC 0.93 Medium
CENTER = 12 0.07 Far

RIGHT = 30 0.33 Medium


PR 0.66 Far

L=8
NEAR MEDIUM

1 1
μX (X) = (10 - L) μX (X) = (L – 1)
9 9

1 1
μX (X) = (2) μX (X) = (7)
9 9

= 0.22 = 0.78
12

C =12

MEDIUM FAR
1 1
μX (X) = (40 - C) μX (X) = (C – 10)
30 30

1 1
μX (X) = (28) μX (X) = (2)
30 30
= 0.93 = 0.07

R = 30
MEDIUM FAR

1 1
μX (X) = (40 - R) μX (X) = (R – 10)
30 30

= 0.33 = 0.66
2. Razonar com Mamdani

L=8 fuzificado es Near com 0.22 y Medium con 0.78


C=12 fuzificado es Medium com 0.93 y Far con 0.07
R=30 fuzificado es Medium com 0.33 y Far con 0.66

$ RULES

R0 if Left is Near then Plau_of_Left is Medium; 0.22


R1 if Center is Near then Plau_of_Center is Medium;
R2 if Right is Near then Plau_of_Right is Medium;

R3 if Left is Near and Center is Near and Right is Near then


Plau_of_Center is High;
R4 if Left is Near and Center is Near then Plau_of_Left is Low;
R5 if Right is Near and Center is Near then Plau_of_Right is Low;

R6 if Left is Medium then Plau_of_Left is High; 0.78


R7 if Center is Medium then Plau_of_Center is High; 0.93
R8 if Right is Medium then Plau_of_Right is High; 0.33

R9 if Left is Medium and Center is Medium and Right is Medium


then Plau_of_Center is VeryHigh; 0.33
R10 if Left is Medium and Center is Medium then Plau_of_Left is
Low; 0.78
R11 if Right is Medium and Center is Medium then Plau_of_Right is
Low; 0.33

R12 if Left is Far then Plau_of_Left is Low;


R13 if Center is Far then Plau_of_Center is Low; 0.07
R14 if Right is Far then Plau_of_Right is Low; 0.66
R15 if Left is Far and Center is Far and Right is Far then
Plau_of_Center is High;

R16 if Left is Medium and Center is Far then Plau_of_Center is


Low; 0.07
R17 if Right is Medium and Center is Far then Plau_of_Center is
Low; 0.07
3. Defuzificación usando fuzzy mean (media difusa)

IDENTIFICANDO SALIDAS DIFUSAS:

1 P_LEFT

R10 R6
0.78

R0
0.22

0.3 0.5 0.8


1

P_LEFT = 0.5 x 0.22 + 0.8 x 0.78 + 0.3 x 0.78 = 0.54


0.22 + 0.78 + 0.78
P_CENTER
1
0.93
R7

0.33 R9
R16
0.07 R13
R17

0.3 0.8 1

P_CENTER = (0.3)(0.07)(3) + (0.8) (0.93) + (1) (0.33) = 0.77


0.07 (3) + 0.33 + 0.93
1 P_RIGHT

0.78 R11

0.66
R14

0.33 R8

0.3 0.8

P_RIGHT = (0.3) (0.66) + (0.3)(0.78) + (0.8) (0.33) = 0.39


0.33 + 0.66 + 0.78

No es correcto, por qué? Verificar la regla 12


En xfuzzy:

FuzzyMean o media difusa, concuerda


con el razonamiento TSK porque las
variables de salida son singleton (líneas
verticales)

You might also like