03-4 - Fuzzy techniques.pdf

Embed Size (px)

Citation preview

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    1/15

    4/28/

    Fuzzy techniques for intensitytrans ormat ons an spat a

    filtering

    Spring 2008 ELEN 4304/5365 DIP 1

    byGlebV.Tcheslavski:[email protected]://ee.lamar.edu/gleb/dip/index.htm

    PreliminariesFuzzy sets are used to incorporate knowledge in the solutions of

    problems, whose formulation is based on imprecise concepts

    Let Z be a set of elements (objects) with a generic element of Z

    denoted as z; that is Z = {z}. This set is called a universe or

    discourse.

    A fuzzy set A in Z is characterized by a membership function A(z)that associates a real number in [0 1] with each element of Z. The

    Spring 2008 ELEN 4304/5365 DIP 2

    it is to one, the higher the grade of membership is.

    In ordinary (crisp) sets, an element either belongs or does not

    belong to a set.

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    2/15

    4/28/

    Preliminaries

    In fuzzy sets, however, we say that all members for which A(z) = 1are full members of the set. All members for which A(z) = 0 are notmembers of the set. The members for which A(z) is between 0 and1 are partial members of the set. Therefore, a fuzzy set is an

    ordered pair consisting of values of z and a corresponding

    membership function:

    ,A z z z Z=

    Spring 2008 ELEN 4304/5365 DIP 3

    For continuous variables, the set A can be infinitely large. For

    discrete values of z, the elements of A are shown explicitly.

    Preliminaries

    Membership function for a Crisp set Membership function for a Fuzzy set

    Limitin the a e to inte er ears, a fuzz set would be:

    Spring 2008 ELEN 4304/5365 DIP 4

    {(1,1), (2,1),...,(20,1), (21,0.9), (22,0.8),...,(25,0.5),...,(29,0.1), (30,0),...}A =

    Age 21 has a 0.9 degree of membership in the set

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    3/15

    4/28/

    Preliminaries/Definitions

    A fuzzy set is empty iff its membership function is identically zero in Z.Two fuzzy sets are equal (A = B) iffA(z) = B(z) for all z Z.

    The complement (NOT) of a fuzzy set A denoted by or NOT(A) isa set whose membership function is (z) = 1 - A(z) for all z Z.

    A fuzzy set A is a subset of a fuzzy set B iffA(z) B(z) for all z Z.

    The union (OR) of two fuzzy sets A and B denoted as AB or A OR B is a fuzzy set U with membership function U(z) = max[A(z), B(z)] forall z Z.

    Spring 2008 ELEN 4304/5365 DIP 5

    The intersection (AND) of two fuzzy sets A and B denoted as AB orA AND B is a fuzzy set I with membership function I(z) = min[A(z),

    B(z)] for all z Z.

    Preliminaries

    Spring 2008 ELEN 4304/5365 DIP 6

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    4/15

    4/28/

    Preliminaries

    Although fuzzy logic and probability may

    ,

    significant difference between them

    While the probability states: There is a 50% chance that the person

    is young (assuming that the person is either young or not), the

    fuzzy statement would be A persons degree of membership among

    Spring 2008 ELEN 4304/5365 DIP 7

    degree).

    Common membership functionsTriangular: 1 ( )

    ( ) 1 ( )

    a z b a b z a

    z z a c a z a c

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    5/15

    4/28/

    Common membership functionsS-shape:

    2

    0

    2

    z a

    z aa z b

    c a

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    6/15

    4/28/

    Using fuzzy sets

    Assume that we need to categorize fruits (based on their colors) intothree groups: verdant (green), half-mature (yellow), and mature

    . ,

    yellow, and red are vague

    notations of our color sensation and are

    needed to be expressed in fuzzy format

    (fuzzified). This is achieved by

    defining membership as a function of

    Spring 2008 ELEN 4304/5365 DIP 11

    . ,

    notion of color is rather linguistic:

    there are regions of wavelengths that

    may be associated with each color!

    Using fuzzy setsThe logics underlying the classification can be expressed by the

    following fuzzy IF-THEN rules:

    R1: IF the color is green, THEN the fruit is verdant

    OR

    R2: IF the color is yellow, THEN the fruit is half-mature

    OR

    R3: IF the color is red, THEN the fruit is mature.

    Spring 2008 ELEN 4304/5365 DIP 12

    ese ru es orma y sum our now e ge a ou e pro em. e

    next step is to determine a procedure utilizing color and the

    knowledge base to create the output of the fuzzy system

    implication (inference).

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    7/15

    4/28/

    Using fuzzy sets

    Fuzzy inputs to the system lead tofuzzy outputs out of it. Unlike the

    independent variable, theindependent variable for theoutput is maturity.

    Two sets of membership functions together with the rule basecontain all the information needed for classification. For

    Spring 2008 ELEN 4304/5365 DIP 13

    ns ance, e express on re ma ure represens anintersection (AND) operator. Since the independent variables

    for the input and output are different, the result will be 2D.

    Using fuzzy sets

    Input or re mature

    Combinedrepresentation

    The resultof AND

    Spring 2008 ELEN 4304/5365 DIP 14

    output

    3( , ) min{ ( ), ( )}red mat z v z v =

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    8/15

    4/28/

    Using fuzzy sets

    In practice, we are interested in the output resulting from aspecific input. Let z0 is a specific value of red. The fuzzy

    3 ,

    { }3 0 3 0( ) min ( ), ( , )redQ v z z v =

    Assuming that

    0( )red z c =

    Spring 2008 ELEN 4304/5365 DIP 15

    We can find the membership function of maturity (for theclass mature) for the specific input (color)

    Using fuzzy setsUsing the same approach, we can find the fuzzy responses fortwo other rules and the specific input z0:

    2 0 2 0( ) min ( ), ( , )yellowQ v z z v =

    { }1 0 1 0( ) min ( ), ( , )greenQ v z z v =

    These equations are the outputs of specific rules for a giveninput. The complete (aggregated) fuzzy output is:

    Spring 2008 ELEN 4304/5365 DIP 16

    1 2 3=Or, in general:

    { }{ }0 0( ) max min ( ), ( , )s rsr

    Q v z z v =

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    9/15

    4/28/

    Using fuzzy sets

    In our situation r= {1, 2, 3}ands = {green, yellow, red}

    Therefore, the response Q of afuzzy system is the union ofindividual fuzzy responses for thegiven input.

    In the fruit example, we notice that

    Spring 2008 ELEN 4304/5365 DIP 17

    1 wavelength z0, the fruit is notverdant.

    Using fuzzy setsThe next step is to obtain a crisp outputv0 from fuzzy setQby the process called defuzzification. One common

    10

    1

    ( )

    ( )

    k

    v

    k

    v

    vQ v

    v

    Q v

    =

    =

    =

    Spring 2008 ELEN 4304/5365 DIP 18

    .In our example, v0 = 72.3, which indicates that a fruit isapproximately 72% mature.

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    10/15

    4/28/

    Using fuzzy sets

    So far, weconsidered IF-THEN

    conditions (IF thecolor is red). Rulescontaining more thanone part are alsopossible:

    Spring 2008 ELEN 4304/5365 DIP 19

    OR consistency issoft, THEN

    mature.

    Using fuzzy setsThe following steps are assumed to implement fuzzy logic:1. Fuzzify the inputs: map each scalar input to the [0 1]

    2. Perform the required fuzzy logical operations: theoutputs of all condition operators must be combined toyield a single value using the appropriate logic.

    3. Apply an implication method: clip each fuzzy outputaccording to the result of corresponding condition rule.

    4. A l an a re ation method to the cli ed out ut

    Spring 2008 ELEN 4304/5365 DIP 20

    fuzzy sets: combine the output of each fuzzy rule in asingle fuzzy set.

    5. Defuzzify the final output fuzzy set: obtain a crisp scalaroutput (for instance, as a center of gravity).

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    11/15

    4/28/

    Using fuzzy sets

    In general, for M IF-THEN rules, N input variables z1, z2, zN,and one output variable v, assuming that conditions are linked,

    1 11 2 12 1 1

    1 21 2 22 2 2

    1 1 2 2

    ( , ) ( , ) ... ( , ) ( , )

    ( , ) ( , ) ... ( , ) ( , )

    ...

    ( , ) ( , ) ... ( , ) ( , )

    N N

    N N

    M M N MN M

    IF z A AND z A AND AND z A THEN v B

    IF z A AND z A AND AND z A THEN v B

    IF z A AND z A AND AND z A THEN v B

    ( , )ELSE v B

    Spring 2008 ELEN 4304/5365 DIP 21

    whereAij is the fuzzy set associated with the ith rule and thejth

    input variable and Bi is the fuzzy set associated with the

    output of the ith rule.

    Using fuzzy setsEvaluation of conditions for the ith rule produces a scalar output(strength level or firing level of the ith rule) as:

    { }min ( ); 1, 2,...iji A j

    z j N = =

    A membership function of a fuzzy setAijevaluated at the value of thejth input.

    i = 1, 2, M

    For the ELSE portion:

    Spring 2008 ELEN 4304/5365 DIP 22

    m n 1 ; 1, 2,...,E i= =

    When instead of AND, the OR logic is used, min should bereplaced by max in the expression for i but not for E.

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    12/15

    4/28/

    Using Fuzzy sets for intensity

    transformationsThe process of contrast enhancement can be stated as

    IF a pixel is dark, THEN make it darker.IF a pixel is gray, THEN make it gray.IF a pixel is bright, THEN make it brighter.

    Then, the input

    Spring 2008 ELEN 4304/5365 DIP 23

    membershipfunctions are:

    Using Fuzzy sets for intensitytransformationsIn this example, we are interested in constant intensities,whose stren th is modified. Therefore theout ut membershifunctions are singletons (constant). The various degrees ofintensity in [0 1] occur when singletons are clipped by thecorresponding rules. In this situation, for the input z0 the output:

    0 0 0

    0

    0 0 0

    ( ) ( ) ( )

    ( ) ( ) ( )

    dark d gray g bright b

    dark gray bright

    z v z v z vv

    z z z

    + + =

    + +

    Spring 2008 ELEN 4304/5365 DIP 24

    Fuzzy image processing is computationally intensive, since thefuzzification, processing conditions for all rules, implication,aggregation, and defuzzification must be applied to every pixelin the input image!

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    13/15

    4/28/

    Using Fuzzy sets for intensity

    transformations

    Spring 2008 ELEN 4304/5365 DIP 25

    Original low-contrastimage (intensities ina narrow range)

    Result of histogramequalization contrast is increased

    but there are areaswith overexposedappearance

    Result of a rule-basedcontrast modificationapproach

    Using Fuzzy sets for intensitytransformations

    Histogram of Histogram ofthe originalimage

    the equalizedimage

    The outputsingletons were

    =

    Outputhistogram

    Spring 2008 ELEN 4304/5365 DIP 26

    vg =127 (midgray);vb =255 (white)

    A faster technique, such as histogram specification, could be used instead.

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    14/15

    4/28/

    Using Fuzzy sets for spatial

    filteringThe basic approach in to define neighborhood propertiescontaining the essence of what the filters need to detect.

    For example, to detect boundaries: if a pixel belongs to auniform region, make it white; else, make it black (white andblack are fuzzy sets). A uniform region can be expressed inthrough intensity differences between the pixel at the center ofa neighborhood and its neighbors.

    For a 3x3 nei hborhood

    Spring 2008 ELEN 4304/5365 DIP 27

    denoting the intensity differencesbetween the ith neighbor and the

    center point as di, a boundaryextraction can be described as

    Using Fuzzy sets for spatialfilteringIF d2 is zero AND d6 is zeroTHEN d5 is whiteIF d6 is zero AND d8 is zeroTHEN d5 is whiteIF d8 is zero AND d4 is zeroTHEN d5 is whiteIF d4 is zero AND d2 is zeroTHEN d5 is white

    ELSE d5 is blackNotice, no diagonal member were considered for simplicity andzero is a fuzzy set.

    Spring 2008 ELEN 4304/5365 DIP 28

    range of intensitylevels for intensitydifferences is[-L+1 L-1]. For a fuzzy set zero For fuzzy sets black

    and white

  • 7/28/2019 03-4 - Fuzzy techniques.pdf

    15/15

    4/28/

    Using Fuzzy sets for spatial

    filtering

    ,rule sets can berepresented as:

    Spring 2008 ELEN 4304/5365 DIP 29

    Using Fuzzy sets for spatialfiltering

    Spring 2008 ELEN 4304/5365 DIP 30

    A CT scan of ahuman head.

    Result of fuzzyspatial filteringextracting edges

    Result afterintensity scaling