Mathematica 9 is now available
Fuzzy Logic Products
-----
 /
Fuzzy Logic
*What's New in Version 2?
*Features
*Sample Images
*Contents
*Q&A
*Examples
*Classifying Houses
*Representing Age
*Finding the Disjunctive Sum
*Natural Numbers
*Fuzzy Hedges
*Distance Relation
*Choosing a Job
*Digital Fuzzy Sets
<Image Processing
*References
*Who's It For?
*Download Product
Manual
*Buy Online
*Technical FAQs
*Documentation
*For More Information
*Higher Education Solutions
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

Example 9: Image Processing

Problem. The table shows the gray levels values for an 8-bit image associated with an array of 25 pixels. Use the enhancement function on this image to recognize the pattern in the image.

image = {{0.55, 0.54, 0.55, 0.43, 0.44}, {0.46, 0.53, 0.41,
0.52, 0.41}, {0.45, 0.57, 0.41, 0.44, 0.55}, {0.43, 0.59, 0.45, 0.53, 0.42}, {0.58, 0.57, 0.6, 0.41, 0.43}} ;

Solution. An image R of m × n dimensions can be considered as an array of fuzzy singletons, each with a value of membership denoting the gray level in the image.  The object of contrast enhancement is to process a given image so that the result is more suitable than the original for a specific application in pattern recognition We will demonstrate enhancement of the image shown in the next figure. First, let's add a function to Fuzzy Logic.

Needs["Graphics`Colors`"] ;

Options[DensePlot] = {Hue -> .75} ;

DensePlot[FuzzyRelation[elems_, opts___], opts1___ ?
OptionQ] := Module[{space, col}, {space} = {UniversalSpace} /. Flatten[{opts}] /. Options[FuzzyRelation] ; {col} =
{Hue} /. Flatten[{opts1}] /. Options[DensePlot] ; Show[Graphics[RasterArray[Transpose[Map[(Hue[col, #1, .75] &)
/@ #1 &, GradeMatrix[elems, space], 2]]], Frame -> True, FrameLabel -> {v, w}, GridLines ->
Automatic]]]

Now, we can plot the image.

fuzzyimage := FromMembershipMatrix[image, {{1, 5.0}, {1,
5}}]

DensePlot[fuzzyimage] ;

[Graphics:HTMLFiles/processing_7.gif]

In general, each membership value in fuzzyimage will be modified to a new membership value to enhance the image by the transformation function Contrast. The IntensifyContrast operator applies a Contrast function and intensifies the contrast between the gray levels in the image. As the number of successive applications of the IntensityContrast increases, the slop of the curve gets steeper.

Contrast[t_] = Which[t <= 0.5, 2 * t^2, t > 0.5
&& t <= 1, 1 - 2 (1 - t)^2] ;

Plot[{Contrast[t], Contrast[Contrast[t]],
Contrast[Contrast[Contrast[t]]], Contrast[Contrast[Contrast[Contrast[t]]]]}, {t, 0, 1}, AspectRatio -> 1,
AxesOrigin -> {0.5, 0.5}, GridLines -> {{0, 0.5, 1}, {0, 0.5, 1}}] ;

[Graphics:HTMLFiles/processing_10.gif]

The graphical effect of this recursive transformation for a typical membership function is shown in the next figure where the number of successive applications of the IntensifyContrast function increases from one to three.

image1 := IntensifyContrast[fuzzyimage]

image2 := IntensifyContrast[image1]

image3 := IntensifyContrast[image2]

image4 := IntensifyContrast[image3]

DensePlot[image4] ;

[Graphics:HTMLFiles/processing_16.gif]

After the original image is processed  by the IntensityContrast operator several times, it is undoubtedly more suitable for the subsequent pattern recognition and classification.  We hope you recognize the pattern in the image. This is a letter A.

Any questions about topics on this page? Click here to get an individual response.