You are on page 1of 15

4/28/2008

Fuzzy techniques for intensity transformations f i and d spatial i l filtering

byGlebV.Tcheslavski:gleb@ee.lamar.edu http://ee.lamar.edu/gleb/dip/index.htm
Spring 2008 ELEN 4304/5365 DIP 1

Preliminaries
Fuzzy 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 value of A(z) at z is a grade of membership of z in A: the closer 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.
Spring 2008 ELEN 4304/5365 DIP 2

4/28/2008

Preliminaries
In fuzzy sets, however, we say that all members for which A(z) = 1 are full members of the set. All members for which A( (z) ) = 0 are not members of the set. The members for which A(z) is between 0 and 1 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 , A ( z ) | z Z }
For continuous variables, the set A can be infinitely large. For discrete values of z, the elements of A are shown explicitly.

Spring 2008

ELEN 4304/5365 DIP

Preliminaries

Membership function for a Crisp set

Membership function for a Fuzzy set

g the age g to integer g y , a fuzzy y set would be: Limiting years,


A = {(1,1), (2,1),..., (20,1), (21, 0.9), (22, 0.8),..., (25, 0.5),..., (29, 0.1), (30, 0),...}
Age 21 has a 0.9 degree of membership in the set

Spring 2008

ELEN 4304/5365 DIP

4/28/2008

Preliminaries/Definitions
A fuzzy set is empty iff its membership function is identically zero in Z. Two fuzzy sets are equal (A = B) iff A(z) = B(z) for all z Z. The complement (NOT) of a fuzzy set A denoted by or NOT(A) is a 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 iff A(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)] for all z Z. The intersection (AND) of two fuzzy sets A and B denoted as AB or A AND B is a fuzzy set I with membership function I(z) = min[A(z), B(z)] for all z Z.

Spring 2008

ELEN 4304/5365 DIP

Preliminaries

Spring 2008

ELEN 4304/5365 DIP

4/28/2008

Preliminaries
Although fuzzy logic and probability may seem as similar concepts concepts, there is a 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 the young people is 50% 50% (meaning that the person is young to some degree).

Spring 2008

ELEN 4304/5365 DIP

Common membership functions


Triangular:
1 (a z ) b ( z ) = 1 ( z a) c 0
1 (a z ) b 1 ( z) = 1 ( z b) d 0 1 (a z ) b ( z ) = 1 0

ab z < a a z < a+c otherwise


a b z < a a z<b b z <b+d otherwise ab z a a<z otherwise
8

Trapezoidal:

Sigma:

Spring 2008

ELEN 4304/5365 DIP

4/28/2008

Common membership functions


S-shape:
0 2 2 z a ca ( z ) = S ( z; a, b, c) = 2 z c 1 2 ca 1 z<a a zb b< zc c<z

Bell-shape:

( z) =

S ( z; c b, c b 2 , c) 1 S ( z; c b, c b 2 , c)
2

zc c<z

Truncated Gaussian:

( z a2) ( z ) = e 2 b 0

ac z a+c otherwise
9

Spring 2008

ELEN 4304/5365 DIP

Common membership functions

Crossover p point

Bandwidth
Spring 2008 ELEN 4304/5365 DIP 10

4/28/2008

Using fuzzy sets


Assume that we need to categorize fruits (based on their colors) into three groups: verdant (green), half-mature (yellow), and mature (red) We notice that the labels green (red). green , 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 color (wavelength). However, the notion of color is rather linguistic: there are regions of wavelengths that may be associated with each color!
Spring 2008 ELEN 4304/5365 DIP 11

Using fuzzy sets


The 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. Th These rules l formally f ll sum our knowledge k l d about b t the th problem. bl The Th next step is to determine a procedure utilizing color and the knowledge base to create the output of the fuzzy system implication (inference).
Spring 2008 ELEN 4304/5365 DIP 12

4/28/2008

Using fuzzy sets


Fuzzy inputs to the system lead to fuzzy outputs out of it. Unlike the input where color was an independent variable, the independent variable for the output is maturity. Two sets of membership functions together with the rule base contain all the information needed for classification. For instance, mature instance the expression e pression red AND mat re represents an intersection (AND) operator. Since the independent variables for the input and output are different, the result will be 2D.

Spring 2008

ELEN 4304/5365 DIP

13

Using fuzzy sets


I Input t for f red d Output for mature

Combined representation for input and output

The result of AND

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


Spring 2008 ELEN 4304/5365 DIP 14

4/28/2008

Using fuzzy sets


In practice, we are interested in the output resulting from a specific input. Let z0 is a specific value of red. The fuzzy is therefore: output due to rule R3 is,

Q3 (v) = min {red ( z0 ), 3 ( z0 , v)}

Assuming that

red ( z0 ) = c

We can find the membership function of maturity (for the class mature) for the specific input (color)
Spring 2008 ELEN 4304/5365 DIP 15

Using fuzzy sets


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

Q2 (v) = min { yellow ( z0 ), 2 ( z0 , v)}


Q1 (v) = min { green ( z0 ), 1 ( z0 , v)}
These equations are the outputs of specific rules for a given input. The complete (aggregated) fuzzy output is:

Q = Q1 OR Q2 OR Q3
Or, in general:
r

Q (v) = max min { s ( z0 ), r ( z0 , v)}


s
Spring 2008 ELEN 4304/5365 DIP

}
16

4/28/2008

Using fuzzy sets


In our situation r = {1, 2, 3} and s = {green, yellow, red} Therefore, the response Q of a fuzzy system is the union of individual fuzzy responses for the given input. In the fruit example, we notice that Q1 is an empty set: for the given wavelength z0, the fruit is not verdant.

Spring 2008

ELEN 4304/5365 DIP

17

Using fuzzy sets


The next step is to obtain a crisp output v0 from fuzzy set Q by the process called defuzzification. One common defuzzification method is to evaluate the center of gravity:

v0 =

vQ(v)
v =1 k

Q (v )
v =1

Here k indicates the number of possible values of Q(v). ) In our example, v0 = 72.3, which indicates that a fruit is approximately 72% mature.

Spring 2008

ELEN 4304/5365 DIP

18

4/28/2008

Using fuzzy sets


So far, we considered IF-THEN rules with single conditions (IF the color is red). Rules containing more than one part are also possible: IF the color is red red OR consistency is soft, THEN mature.
Spring 2008 ELEN 4304/5365 DIP 19

Using fuzzy sets


The following steps are assumed to implement fuzzy logic: 1. Fuzzify the inputs: map each scalar input to the [0 1] interval by the applicable membership function; 2. Perform the required fuzzy logical operations: the outputs of all condition operators must be combined to yield a single value using the appropriate logic. 3. Apply an implication method: clip each fuzzy output according to the result of corresponding condition rule. 4. Apply pp y an aggregation gg g method to the clipped pp output p fuzzy sets: combine the output of each fuzzy rule in a single fuzzy set. 5. Defuzzify the final output fuzzy set: obtain a crisp scalar output (for instance, as a center of gravity).
Spring 2008 ELEN 4304/5365 DIP 20

10

4/28/2008

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 by ANDs, ANDs a fuzzy rule is formulated as
IF ( z1 , A11 ) AND ( z2 , A12 ) AND ... AND ( z N , A1N ) IF ( z1 , A21 ) AND ( z2 , A22 ) AND ... AND ( z N , A2 N ) THEN (v, B1 ) THEN (v, B2 )

... IF ( z1 , AM 1 ) AND ( z2 , AM 2 ) AND ... AND ( z N , AMN ) THEN (v, BM ) ELSE (v, BE )

where Aij is the fuzzy set associated with the ith rule and the jth input variable and Bi is the fuzzy set associated with the output of the ith rule.
Spring 2008 ELEN 4304/5365 DIP 21

Using fuzzy sets


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

i = min A ( z j ); j = 1, 2,...N
ij

i = 1, 2, M

A membership function of a fuzzy set Aij evaluated at the value of the jth input.

For the ELSE portion:

E = min i {1 i ; i = 1, 1 2,..., 2 M}
When instead of AND, the OR logic is used, min should be replaced by max in the expression for i but not for E.
Spring 2008 ELEN 4304/5365 DIP 22

11

4/28/2008

Using Fuzzy sets for intensity transformations


The 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 and output membership functions are:

Spring 2008

ELEN 4304/5365 DIP

23

Using Fuzzy sets for intensity transformations


In this example, we are interested in constant intensities, whose strength is modified. Therefore, the output membership functions are singletons (constant). The various degrees of intensity in [0 1] occur when singletons are clipped by the corresponding rules. In this situation, for the input z0 the output:

v0 =

dark ( z0 ) vd + gray ( z0 ) vg + bright ( z0 ) vb dark ( z0 ) + gray ( z0 ) + bright ( z0 )

Fuzzy image processing is computationally intensive, since the fuzzification, processing conditions for all rules, implication, aggregation, and defuzzification must be applied to every pixel in the input image!
Spring 2008 ELEN 4304/5365 DIP 24

12

4/28/2008

Using Fuzzy sets for intensity transformations

Original low-contrast image (intensities in a narrow range)

Result of histogram Result of a rule-based equalization contrast modification contrast is increased approach but there are areas with overexposed appearance
ELEN 4304/5365 DIP 25

Spring 2008

Using Fuzzy sets for intensity transformations


Histogram g of the original image Histogram g of the equalized image

The output singletons were vd = 0 (black); vg = 127 (mid gray); vb = 255 (white)

Output histogram

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


Spring 2008 ELEN 4304/5365 DIP 26

13

4/28/2008

Using Fuzzy sets for spatial filtering


The basic approach in to define neighborhood properties containing the essence of what the filters need to detect. For example, to detect boundaries: if a pixel belongs to a uniform region, make it white; else, make it black (white and black are fuzzy sets). A uniform region can be expressed in through intensity differences between the pixel at the center of a neighborhood and its neighbors. g , For a 3x3 neighborhood, denoting the intensity differences between the ith neighbor and the center point as di, a boundary extraction can be described as
Spring 2008 ELEN 4304/5365 DIP 27

Using Fuzzy sets for spatial filtering


IF d2 is zero AND d6 is zero THEN d5 is white IF d6 is zero AND d8 is zero THEN d5 is white IF d8 is zero AND d4 is zero THEN d5 is white IF d4 is zero AND d2 is zero THEN d5 is white ELSE d5 is black Notice, no diagonal member were considered for simplicity and zero is a fuzzy set. Note: possible range of intensity levels for intensity differences is [-L+1 L-1].
Spring 2008

For a fuzzy set zero


ELEN 4304/5365 DIP

For fuzzy sets black and white 28

14

4/28/2008

Using Fuzzy sets for spatial filtering


Graphically, four Graphically rule sets can be represented as:

Spring 2008

ELEN 4304/5365 DIP

29

Using Fuzzy sets for spatial filtering

A CT scan of a human head.

Result of fuzzy spatial filtering extracting edges


ELEN 4304/5365 DIP

Result after intensity scaling

Spring 2008

30

15

You might also like