Group 13 Fuzzy Techniques in Image Processing

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

Fuzzy techniques in image

processing
Team Memebers

Sai 21MIP10013
Rakesh 21MIP10015
Shivam 21MIP10033
Mj Sumedh 21BAI10282
Ankit 21BAI10409
PRESENTATION FLOW
1.Introduction to Fuzzy logic
1.1 Fuzzy Sets
1.2 Fuzzy Infrence System
2 Fuzzy Image Processing Model
3 Applications
3.1 Noise Detection and Removal
3.2 Edge detection
3.3 Contrast Enahancement
Fuzzy Sets
Fuzzy set theory is the extension of conventional (crisp) set
theory

Fuzzy logic began with the introduction of Fuzzy Set Theory


by Lotfi Zadeh in 1965.
Fuzzy Set - Sets whose elements have degrees of
membership.

A fuzzy subset A of a set X is characterized by assigning to


each element of x in X the degree of membership of x in A. •
Example let X={x|x is a person} and A={x|x is an oldperson}
Fuzzy Sets contnd..
In Propositional Logic, truth values are either True or False

Fuzzy logic is a type of Many-Valued Logic.

There are more than two truth values


The interval [0,1] represents the possible truth values .
0 is absolute falsity , 1 is absolute truth

​Instead of just black and white, the color belonging to a set has
degree of whiteness &blackness
Fuzzy Sets contnd..

You can see that in fuzzy set H, graph the values are
from [0,1] but in crisp set it is 0 or 1 only.
Fuzzy Sets contnd..

Instead of just black and white, the color belonging to a


set has degree of whiteness &blackness
Fuzzy Sets contnd..
🞂​As an example, we can regard the variable color as a fuzzy set
color = {yellow, orange, red, violet, blue}
Fuzzy Infrence System
A Fuzzy Inference System (FIS) is a computational model that
simulates human decision-making processes by incorporating
fuzzy logic. It enables systems to make decisions based on
vague, uncertain, or incomplete information, similar to how
humans make decisions.

Components of FIS:
1.Fuzzification.
2.Knowledge Base.
3.Infrence Engine.
4.Fuzzy logic Operations.
Fuzzy Infrence System Contnd.
Fuzzy Infrence System Contnd.
Fuzzy Infrence System Contnd.

🞂​Rules
If x is A1 and y is B1 then z is C1
If x is A2 and y is B2
then z is C2
Fuzzy Logic in Image Processing
1.Introduction to image processing and its significance
across various fields:

Image processing plays a crucial role in diverse fields such


as medicine, astronomy, national security, autonomous
systems, product quality, and industrial applications.

It involves manipulating digital images to enhance their


quality, extract information, or make them suitable for
analysis
Fuzzy Logic in Image Processing contnd.
2.Challenges in simulating human visual systems using
traditional logic approaches:
Traditional logic approaches often struggle to capture the
complexities of human perception, which involve uncertainty
and subjectivity.

Modeling subjective concepts and dealing with uncertain


information pose significant challenges in developing
accurate image processing algorithms.
Fuzzy Logic in Image Processing contnd.
3.Introduction of fuzzy logic as a better framework for
handling uncertainty and subjectivity in image processing
algorithms:
Fuzzy logic offers a more flexible and robust framework for
handling uncertainty and subjectivity compared to traditional
crisp logic.

By incorporating fuzzy sets and fuzzy rules, fuzzy logic enables


systems to make decisions based on imprecise or incomplete
information, mimicking human reasoning processes.
Fuzzy Logic in Image Processing contnd.
3.Introduction of fuzzy logic as a better framework for
handling uncertainty and subjectivity in image processing
algorithms:
Fuzzy logic offers a more flexible and robust framework for
handling uncertainty and subjectivity compared to traditional
crisp logic.

By incorporating fuzzy sets and fuzzy rules, fuzzy logic enables


systems to make decisions based on imprecise or incomplete
information, mimicking human reasoning processes.
Fuzzy Logic in Image Processing contnd.
4.Fuzzy image processing flow
Fuzzy Logic in Image Processing contnd.

Fig .2 Steps of Fuzzy image processsing


Applications.

1.Noise Detection and Removal


The Filter consists of two stages:-
1.The first stage computes a fuzzy derivative for eight
different directions.
2. The second stage uses these fuzzy derivates to perform
fuzzy smoothing by weighting the contributions of neighboring
pixel values.

Both stages are based on fuzzy rules which make use of


membership functions. Fuzzy techniques have already been
applied in several domains of image processing (e.g., filtering
interpolation , and morphology)
Applications.
2.Edge Detection
Introduction
Edge detection is crucial in image processing for identifying
boundaries representing significant changes in intensity or
color.

Accurate edge detection is essential for object recognition,


image segmentation, and feature extraction.

Traditional methods like Sobel operator or Canny edge detector


rely on fixed parameters.

Suboptimal results can occur in images with varying


complexities or lighting conditions.
Applications.
2.Edge Detection
Fuzzy Adaptive Edge Definition:

FAED incorporates fuzzy logic to automatically adjust edge


detection parameters, providing more accurate results across
different types of images..

The FAED algorithm begins by assessing the complexity of the


image using predefined metrics or features.

Based on the complexity assessment, fuzzy rules are applied to


dynamically adjust edge detection parameters such as
threshold values or filter coefficients,the adaptive nature of
FAED ensures optimal edge detection performance in diverse
image
Thank you
for listening us.
Double-click (or enter) to edit

1 !pip install -U scikit-fuzzy


2

Collecting scikit-fuzzy
Downloading scikit-fuzzy-0.4.2.tar.gz (993 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 994.0/994.0 kB 11.1 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy>=1.6.0 in /usr/local/lib/python3.10/dist-packages (from scikit-fuzzy) (1.25.2)
Requirement already satisfied: scipy>=0.9.0 in /usr/local/lib/python3.10/dist-packages (from scikit-fuzzy) (1.11.4)
Requirement already satisfied: networkx>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from scikit-fuzzy) (3.2.1)
Building wheels for collected packages: scikit-fuzzy
Building wheel for scikit-fuzzy (setup.py) ... done
Created wheel for scikit-fuzzy: filename=scikit_fuzzy-0.4.2-py3-none-any.whl size=894078 sha256=3da63d9c193f372afb5176cd1ef48c092adf735eafc55a5f17a784df9feb7816
Stored in directory: /root/.cache/pip/wheels/4f/86/1b/dfd97134a2c8313e519bcebd95d3fedc7be7944db022094bc8
Successfully built scikit-fuzzy
Installing collected packages: scikit-fuzzy
Successfully installed scikit-fuzzy-0.4.2

1 import numpy as np
2 import matplotlib.pyplot as plt
3 from skimage import io
4 from scipy.signal import convolve2d
5 from skfuzzy import gaussmf, trimf, defuzz, interp_membership
6 from skfuzzy.control import ControlSystem, ControlSystemSimulation, Antecedent, Consequent
7

1 import skfuzzy.control
2
3 # Check if the Rule class is present in the skfuzzy.control module
4 if 'Rule' in dir(skfuzzy.control):
5 print("Rule class found in skfuzzy.control module.")
6 else:
7 print("Rule class not found in skfuzzy.control module.")
8

Rule class found in skfuzzy.control module.

keyboard_arrow_down Reading the image And Converting to grayscale


1 Irgb = io.imread('/content/fruits.png')
1 # Plot the original image
2 plt.figure()
3 plt.imshow(Irgb)
4 plt.title('Original Image')
5 plt.show()

output

Double-click (or enter) to edit

1 Igray = 0.2989 * Irgb[:,:,0] + 0.5870 * Irgb[:,:,1] + 0.1140 * Irgb[:,:,2]

keyboard_arrow_down Ploting the Grayscale image


1 plt.figure()
2 plt.imshow(Igray, cmap='gray')
3 plt.title('Input Image in Grayscale')
4 plt.show()
keyboard_arrow_down Convert image to double precision
1 I = Igray.astype(float)
2 scalingFactor = 255.0 # Assuming the maximum value of pixel intensity is 255
3 I = I / scalingFactor

keyboard_arrow_down Define gradient kernels


1 Gx = [[-1, 1]]
2 Gy = [[-1], [1]]

keyboard_arrow_down Compute gradient in x and y directions


1 Ix = convolve2d(I, Gx, mode='same')
2 Iy = convolve2d(I, Gy, mode='same')
keyboard_arrow_down Plot the gradient images
1 plt.figure()
2 plt.imshow(Ix, cmap='gray')
3 plt.title('Ix')
4 plt.show()

1 plt.figure()
2 plt.imshow(Iy, cmap='gray')
3 plt.title('Iy')
4 plt.show()
keyboard_arrow_down Create Fuzzy Logic system for edge detection
1 edgeFIS = ControlSystem()

keyboard_arrow_down Define input and output variables


1 Ix_antecedent = Antecedent(np.arange(-1, 1, 0.01), 'Ix')
2 Iy_antecedent = Antecedent(np.arange(-1, 1, 0.01), 'Iy')
3 Iout_consequent = Consequent(np.arange(0, 1, 0.01), 'Iout')

keyboard_arrow_down Define membership functions


1 sx = 0.1
2 sy = 0.1
3 Ix_antecedent['zero'] = gaussmf(Ix_antecedent.universe, 0, sx)
4 Iy_antecedent['zero'] = gaussmf(Iy_antecedent.universe, 0, sy)
5 Iout_consequent['white'] = trimf(Iout_consequent.universe, [0, 0, 0.7])
6 Iout_consequent['black'] = trimf(Iout_consequent.universe, [0.3, 1, 1])
7

keyboard_arrow_down Define the rule base


1 # Importing Rule explicitly from skfuzzy.control
2 from skfuzzy.control import Rule
3
4 rule1 = Rule(Ix_antecedent['zero'] & Iy_antecedent['zero'], Iout_consequent['white'])
5 rule2 = Rule(~(Ix_antecedent['zero'] & Iy_antecedent['zero']), Iout_consequent['black'])
6

keyboard_arrow_down Create the ControlSystem object with rules defined and Create simulation object
1 edgeFIS = ControlSystem([rule1, rule2])
2
3 # Create simulation object
4 edgeControlSystem = ControlSystemSimulation(edgeFIS)

Double-click (or enter) to edit

keyboard_arrow_down Evaluate the fuzzy logic system


1 Ieval = np.zeros_like(I)
2 for i in range(I.shape[0]):
3 for j in range(I.shape[1]):
4 edgeControlSystem.input['Ix'] = Ix[i, j]
5 edgeControlSystem.input['Iy'] = Iy[i, j]
6 edgeControlSystem.compute()
7 Ieval[i, j] = edgeControlSystem.output['Iout']
8
keyboard_arrow_down Plot the original grayscale image
1 plt.figure()
2 plt.imshow(I, cmap='gray')
3 plt.title('Original Grayscale Image')
4 plt.show()

keyboard_arrow_down Plot the edge detection result using fuzzy logic


1 plt.figure()
2 plt.imshow(Ieval, cmap='gray')
3 plt.title('Edge Detection Using Fuzzy Logic')
4 plt.show()

You might also like