Image Classification Using Edge Detection Withe Fuzzy Logic: Par: Chettouh Safieddine Sohbi Salem Hammoudi Mabrouk

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Image classification using edge

Detection withe fuzzy logic

par:
Chettouh safieddine
Sohbi salem
Hammoudi mabrouk

ALLPPT.com _ Free PowerPoint Templates, Diagrams and Charts


1. INTRODUCTION
an edge is defined as an abrupt variation in pixel intensity within an image
while the process of detecting outlines of an object and boundaries between
objects and the background in the image is known as edge detection. Edge
detection is a very important tool widely used in many computer vision and
image processing applications. Earlier edge detection methods, such as
Sobel, Prewitt, Kirsch and Robert are based on the calculation of the
intensity gradient magnitude at each image pixel. In these algorithms,
the gradient value is compared to the threshold value and a pixel location is
classified as an edge if the value of the gradient is higher than a threshold.
Gradient-based edge detectors have a major drawback of being very
sensitive to noise.
In order to counter noise problems Canny proposed an approach to edge
detection in which the image is convolved with the first order derivatives of
Gaussian filter for smoothing in the local gradient direction followed by
edge detection and thresholding [Canny 1986]. Extensions of Canny edge
detector can be found in [Laligant et al. 1994].
I. INTRODUCTION
Edge detection represents an extremely important step facilitating
higher-level image analysis and therefore remains an area of active research,
with new approaches continually being developed. Recent examples include
edge detectors using fuzzy logic, neural networks, or wavelets [Sun and
Sclabassi 1995, Law et al. 1996, Bezdek et al. 1996, Wang et al. 2005].
Comparison of edge detection approaches and an assessment of their per-
formance may be found in [Demigny et al. 1995, Ramesh and Haralick 1994].
In this paper, fuzzy logic based approach to edge.
II. APPLICATION OF FUZZY LOGIC BASED EDGE DETECTION :

Fuzzy logic represents a powerful approach to decision making [Zadeh 1965,


Kaufmann 1975, Bezdek 1981]. Since the concept of fuzzy logic was formu-
lated in 1965 by Zadeh, many researches have been carried out on its
application in the various areas of digital image processing such as image
quality assessment, edge detection, image segmentation, etc. Many tech-
niques have been suggested by researchers in the past for fuzzy logic-based
edge
detection [Cheung and Chan 1995, Kuo, et al. 1997, El-Khamy et al. 2000]. In
[Zhao, et al. 2001], Zhao, et al. proposed an edge detection technique based
on probability partition of the image into 3-fuzzy partitions (regions) and the
principle of maximum entropy for finding the parameters value that result in
the best compact edge representation of images. In their proposed
technique the necessary condition for the entropy function to reach its
maximum is derived. Based on this condition an effective algorithm for
three-level thresholding is obtained. Several approaches on fuzzy logic based
edge detection have been reported based on fuzzy If-Then rules [Tao, et al.
1993, Li 1997].
II. APPLICATION OF FUZZY LOGIC BASED EDGE DETECTION :

In most of these methods, adjacent points of pixels are assumed in some classes and
then fuzzy
system inference are implemented using appropriate membership function, defined for
each
class [Mahani, et al. 2008]. In Liang, et al. [Liang, et al. 2003], adjacent points are as-
sumed
as 3×3 sets around the concerned point. By predefining membership function to de-
tect edges.
In these rules discontinuity in the color of different 3×3 sets, edges are extracted. It
uses 5 fuzzy
rules and predefined membership function to detect edges. In these rules discontinu-
ity of adjacent point around the concerned point are investigated. If this difference is
similar to one of predefined sets, the pixel is
assumed as edge.A similar work is proposed by Mansoori, et al. [Mansoori, et al.
2006], wherein
adjacent points of each pixel are grouped in six different set. Then by using of appro-
priate bell shape membership function, the value from zero to one is determined for
each group. Based on
the membership.
stages of work :

1-import rgb image


2-convert color image to grayscal image
3-convert image to Doubl-prcision Data
4-calculair Image gradiant
5-plot the image gradiant
6-create a fuzzy inferenc system (FIS) for edge detection edgeFIS
7- specefy the image gradiant Ix and Iy as a input of edgeFIS
8-specefy a zero-mean guasian membership function of each input
9- specefy the intesity of te edge detected image as an output of the edgeFIS
10- specefy the triangular membership function whit and black ,for Iout
11- specefy FIS rules ,Add rules to make a pixl whit if it belong to a uniform region
and black otherwis
12-Evaleat the output of the edge detecter for each row of pixel in I using corespond-
ing rows Ix and Iy as inputs
13-plot the original image grayscal
14- plot the detected edges Ieval
Result of edge detection :
Image classification :

Images are categorized by entering the image into the algorithm, then it
tells you to which category it belongs
For image classification there are two algorithms, one for training and one
for testing

Training algorithme :
You enter an RGB image and detect the edges to produce a black and white
image, then save the image values in the db matrix.
progremme

clc;
clear all;
close all;
%% Taking an Image
[fname, path]=uigetfile('.png','Open an Image as input for training');
fname=strcat(path, fname);
im=imread(fname);
%%%%%%%%%%%%
Irgb = im;
Igray = rgb2gray(Irgb);

figure
image(Igray,'CDataMapping','scaled')
colormap('gray')
title('Input Image in Grayscale')
I = im2double(Igray);
Gx = [-1 1];
Gy = Gx';
Ix = conv2(I,Gx,'same');
Iy = conv2(I,Gy,'same');
figure
image(Ix,'CDataMapping','scaled')
colormap('gray')
title('Ix')
figure
image(Iy,'CDataMapping','scaled')
colormap('gray')
title('Iy')
% edgeFIS=mamfis;
edgeFIS = mamfis('Name','edgeDetection');
edgeFIS = addInput(edgeFIS,[-1 1],'Name','Ix');
edgeFIS = addInput(edgeFIS,[-1 1],'Name','Iy');
sx = 0.1;
sy = 0.1;
edgeFIS = addMF(edgeFIS,'Ix','gaussmf',[sx 0],'Name','zero');
edgeFIS = addMF(edgeFIS,'Iy','gaussmf',[sy 0],'Name','zero');
edgeFIS = addOutput(edgeFIS,[0 1],'Name','Iout');
wa = 0.1;
wb = 1;
wc = 1;
ba = 0;
bb = 0;
bc = 0.7;
edgeFIS = addMF(edgeFIS,'Iout','trimf',[wa wb wc],'Name','white');
edgeFIS = addMF(edgeFIS,'Iout','trimf',[ba bb bc],'Name','black');
figure
subplot(2,2,1)
plotmf(edgeFIS,'input',1)
title('Ix')
subplot(2,2,2)
plotmf(edgeFIS,'input',2)
title('Iy')
subplot(2,2,[3 4])
plotmf(edgeFIS,'output',1)
title('Iout')
r1 = "If Ix is zero and Iy is zero then Iout is white";
r2 = "If Ix is not zero or Iy is not zero then Iout is black";
edgeFIS = addRule(edgeFIS,[r1 r2]);
edgeFIS.Rules

Ieval = zeros(size(I));
for ii = 1:size(I,1)
Ieval(ii,:) = evalfis(edgeFIS,[(Ix(ii,:));(Iy(ii,:))]');
end

figure
image(I,'CDataMapping','scaled')
colormap('gray')
title('Original Grayscale Image')

figure
image(Ieval,'CDataMapping','scaled')
colormap('gray')
title('Edge Detection Using Fuzzy Logic')
%%%%%%%%%%%%%%
%%im=im2bw(im);
imshow(Ieval);
title('Input Image');
c=input('Enter the Class(Number from 1-12)');
%% Feature Extraction
F=FeatureStatistical(Ieval);
try
load db;
F=[F c];
db=[db; F];
save db.mat db
catch
db=[F c]; % 10 12 1
save db.mat db
end
testing algorithme :
You enter an RGB image and then the algorithm transforms
the image using boundary detection (fuzzy logic)
Then it compares its values to the values in the db array and
tells you to which class it belongs.
 
%% Test Image
clc;
clear all;
close all;
[fname, path]=uigetfile('.png','provide an Image for testing');
fname=strcat(path, fname);
im=imread(fname);
%edge detection using fuzzy logic
Irgb = im;
Igray = rgb2gray(Irgb);

figure
image(Igray,'CDataMapping','scaled')
colormap('gray')
title('Input Image in Grayscale')
I = im2double(Igray);
Gx = [-1 1];
Gy = Gx';
Ix = conv2(I,Gx,'same');
Iy = conv2(I,Gy,'same');
figure
figure
image(Ix,'CDataMapping','scaled')
colormap('gray')
title('Ix')
figure
image(Iy,'CDataMapping','scaled')
colormap('gray')
title('Iy')
% edgeFIS=mamfis;
edgeFIS = mamfis('Name','edgeDetection');
edgeFIS = addInput(edgeFIS,[-1 1],'Name','Ix');
edgeFIS = addInput(edgeFIS,[-1 1],'Name','Iy');
sx = 0.1;
sy = 0.1;
edgeFIS = addMF(edgeFIS,'Ix','gaussmf',[sx 0],'Name','zero');
edgeFIS = addMF(edgeFIS,'Iy','gaussmf',[sy 0],'Name','zero');
edgeFIS = addOutput(edgeFIS,[0 1],'Name','Iout');
wa = 0.1;
wb = 1;
wc = 1;
ba = 0;
bb = 0;
bc = 0.7;
edgeFIS = addMF(edgeFIS,'Iout','trimf',[wa wb wc],'Name','white');
edgeFIS = addMF(edgeFIS,'Iout','trimf',[ba bb bc],'Name','black');
figure
subplot(2,2,1)
plotmf(edgeFIS,'input',1)
title('Ix')
subplot(2,2,2)
plotmf(edgeFIS,'input',2)
title('Iy')
subplot(2,2,[3 4])
plotmf(edgeFIS,'output',1)
title('Iout')
r1 = "If Ix is zero and Iy is zero then Iout is white";
r2 = "If Ix is not zero or Iy is not zero then Iout is black";
edgeFIS = addRule(edgeFIS,[r1 r2]);
edgeFIS.Rules

Ieval = zeros(size(I));
for ii = 1:size(I,1)
Ieval(ii,:) = evalfis(edgeFIS,[(Ix(ii,:));(Iy(ii,:))]');
end

figure
image(I,'CDataMapping','scaled')
colormap('gray')
title('Original Grayscale Image')

figure
image(Ieval,'CDataMapping','scaled')
colormap('gray')
title('Edge Detection Using Fuzzy Logic')
%%%%%%%%%

%%im=im2bw(im);
imshow(Ieval);
title('Test Image');
%% Find the class the test image belongs
Ftest=FeatureStatistical(Ieval);
%% Compare with the feature of training image in the database
load db.mat
Ftrain=db(:,1:2);
Ctrain=db(:,3);
for (i=1:size(Ftrain,1));
dist(i,:)=sum(abs(Ftrain(i,:)-Ftest));
end
m=find(dist==min(dist),1);
det_class=Ctrain(m);
msgbox(strcat('Detected Class=',num2str(det_class)));

 
 
 

You might also like