75 views

Uploaded by Amiliya Emil

Fuzzy Logic Image Processing - MATLAB & Simulink Example

save

You are on page 1of 8

**Fuzzy Logic Image Processing
**

This example shows how to use Fuzzy Logic Toolbox software for image processing. Open This Example

Specifically, this example shows how to detect edges in an image.

**An edge is a boundary between two uniform regions. You can detect an edge by comparing the intensity of
**

neighboring pixels. However, because uniform regions are not crisply defined, small intensity differences between

two neighboring pixels do not always represent an edge. Instead, the intensity difference might represent a shading

effect.

The fuzzy logic approach for image processing allows you to use membership functions to define the degree to

which a pixel belongs to an edge or a uniform region.

**Import RGB Image and Convert to Grayscale
**

Import the image into MATLAB.

Irgb = imread('peppers.png');

Irgb is a 384 x 512 x 3 uint8 array. The three channels of Irgb (third array dimension) represent the red, green,

and blue intensities of the image.

Convert Irgb to grayscale so that you can work with a 2-D array instead of a 3-D array. Use the standard NTSC

conversion formula to calculate the effective luminance of each pixel.

Igray = 0.2989*Irgb(:,:,1)+0.5870*Irgb(:,:,2)+0.1140*Irgb(:,:,3);

**figure; image(Igray,'CDataMapping','scaled'); colormap('gray');
**

title('Input Image in Grayscale')

http://www.mathworks.com/help/fuzzy/examples/fuzzy-logic-image-processing.html Page 1 of 8

mathworks. Convert Image to Double-Precision Data The Fuzzy Logic Toolbox software operates on double-precision numbers only. convert Igray.com/help/fuzzy/examples/fuzzy-logic-image-processing. classType = class(Igray).MATLAB & Simulink Example 3/9/16. Calculate the image gradient along the x-axis and y-axis. Obtain Image Gradient The fuzzy logic edge-detection algorithm for this example relies on the image gradient to locate breaks in uniform regions.Fuzzy Logic Image Processing . you can use the im2double function in the Image Processing Toolbox software to convert Igray to a scaled. I = I/scalingFactor. you can use the rgb2gray function in the Image Processing Toolbox software to convert Irgb to grayscale. Scale I so that its elements are in the [0 1] range. I = double(Igray). Alternatively. scalingFactor = double(intmax(classType)). 18:38 Alternatively. double-precision image.html Page 2 of 8 . http://www. to a double array. all elements of I are in that range too. So. a uint8 array. Because uint8 values are in the [0 2^8-1] range.

'CDataMapping'. colormap('gray').Gx. Ix = conv2(I. 18:38 Gx = [-1 1]. figure. image(Iy.'CDataMapping'.'same'). title('Ix'). Gy = Gx'.'same').MATLAB & Simulink Example 3/9/16.Gy.html Page 3 of 8 .Fuzzy Logic Image Processing . title('Iy').'scaled'). http://www. image(Ix. Iy = conv2(I. colormap('gray').'scaled').mathworks. figure.com/help/fuzzy/examples/fuzzy-logic-image-processing.

'input'. http://www.'gaussmf'. edgeFIS = addvar(edgeFIS.1.com/help/fuzzy/examples/fuzzy-logic-image-processing.[sx 0]).[-1 1]). you can use the imfilter.[sy 0]). edgeFIS = addmf(edgeFIS.[-1 1]). Define Fuzzy Inference System (FIS) for Edge Detection Create a Fuzzy Inference System (FIS) for edge detection. 18:38 Gx and Gy are simple gradient filters. Specify a zero-mean Gaussian membership function for each input.'input'.'Iy'. Ix and Iy. The gradient values are in the [-1 1] range. You can use other filters to obtain the image gradients. If the gradient value for a pixel is 0.'zero'. as the inputs of edgeFIS.'gaussmf'.mathworks. edgeFIS = addmf(edgeFIS. to obtain a matrix containing the x-axis gradients of I. or imgradient functions to obtain the image gradients. sy = 0.2.MATLAB & Simulink Example 3/9/16. edgeFIS.1.'input'.1. Specify the image gradients. You convolve I with Gx.Fuzzy Logic Image Processing . using the conv2 function. You can change the values of sx and sy to adjust the edge detector performance. see Convolution. imgradientxy. if you have the Image Processing Toolbox software. edgeFIS = addvar(edgeFIS. Alternatively. Similarly. Increasing the values makes the algorithm less sensitive to the edges in the image and decreases the intensity of the detected edges. sx and sy specify the standard deviation for the zero membership function for the Ix and Iy inputs. you convolve I with Gy to obtain the y-axis gradients of I.'zero'. For information about how you can filter an image using convolution. sx = 0. edgeFIS = newfis('edgeDetection').'Ix'. such as the Sobel operator or the Prewitt operator.html Page 4 of 8 .'input'. then it belongs to the zero membership function with a degree of 1.

'output'.1. 18:38 Specify the intensity of the edge-detected image as an output of edgeFIS.Fuzzy Logic Image Processing .'white'.1). plotmf(edgeFIS.1. title('Iout') Specify FIS Rules Add rules to make a pixel white if it belongs to a uniform region. white and black.'trimf'.1).[ba bb bc]). and bc to adjust the edge detector performance.2). title('Ix'). figure subplot(2. edgeFIS = addmf(edgeFIS.2.[wa wb wc]). edgeFIS = addmf(edgeFIS.'Iout'.[0 1]).com/help/fuzzy/examples/fuzzy-logic-image-processing. make the pixel black.2. http://www. and end of the triangles of the membership functions. title('Iy').2). subplot(2. for Iout. As you can with sx and sy. wb = 1.'input'.'output'. you can change the values of wa.mathworks.'output'. Otherwise. Specify the triangular membership functions. plotmf(edgeFIS.1). wa = 0. ba = 0. wc. bb = 0. bc = . subplot(2. edgeFIS = addvar(edgeFIS.'input'.'trimf'. plotmf(edgeFIS. bb. peak. ba. Plot the membership functions of the inputs/outputs of edgeFIS.2.[3 4]).7.html Page 5 of 8 . The triplets specify the start. These parameters influence the intensity of the detected edges.'output'. wb.1. wc = 1.MATLAB & Simulink Example 3/9/16.'black'.

html Page 6 of 8 . title('Edge Detection Using Fuzzy Logic') http://www. image(Ieval.1) Ieval(ii.edgeFIS).'CDataMapping'.'scaled').:) = evalfis([(Ix(ii.r2). showrule(edgeFIS) ans = 1.:)).r). r = char(r1. Ieval = zeros(size(I)).'scaled'). If (Ix is not zero) or (Iy is not zero) then (Iout is black) (1) Evaluate FIS Evaluate the output of the edge detector for each row of pixels in I using corresponding rows of Ix and Iy as inputs. r2 = 'If Ix is not zero or Iy is not zero then Iout is black'. image(I. colormap('gray'). If (Ix is zero) and (Iy is zero) then (Iout is white) (1) 2. end Plot Results figure. colormap('gray').(Iy(ii.:)).'CDataMapping'. 18:38 r1 = 'If Ix is zero and Iy is zero then Iout is white'.% Preallocate the output matrix for ii = 1:size(I.mathworks. edgeFIS = parsrule(edgeFIS.MATLAB & Simulink Example 3/9/16.com/help/fuzzy/examples/fuzzy-logic-image-processing. title('Original Grayscale Image') figure.Fuzzy Logic Image Processing .]'.

18:38 Summary http://www.html Page 7 of 8 .MATLAB & Simulink Example 3/9/16.com/help/fuzzy/examples/fuzzy-logic-image-processing.Fuzzy Logic Image Processing .mathworks.

You defined the gradient as zero using Gaussian membership functions for your FIS inputs.MATLAB & Simulink Example 3/9/16.Fuzzy Logic Image Processing .html Page 8 of 8 .com/help/fuzzy/examples/fuzzy-logic-image-processing. 18:38 You detected the edges in an image using a FIS. If the gradient for a pixel is not zero. http://www. comparing the gradient of every pixel in the x and y directions. then the pixel belongs to an edge (black).mathworks.

- Edge DetectionUploaded byAlex Chen
- Course Work Assignment Paper 2012Uploaded bySilvi Valimaña
- image processing using labviewUploaded bysandipnair06
- 1506.08704 (1)Uploaded byRobert Robinson
- Comp Vis Python 3Uploaded byJean Philippeaux
- Single Frontal Face Detection by Finding Dark Pixel Group and Comparing XyUploaded byIAEME Publication
- DIGITAL IMAGE PROCESSING Presentation.docUploaded byHacker4a4
- Intensity and Texture Gradient Based Boundary Detection Algorithm for Medical ImageUploaded byseventhsensegroup
- ipquestionsUploaded byshreetam behera
- DIP_2011_Labs_02Uploaded byraw.junk
- Adams 2008r1 Doc ReleaseUploaded byVivek_subzero
- ENG3104_assignment3 (1)Uploaded byNayim Mohammad
- 40Uploaded byRiski Prahmadani
- Astroart 5.0 User's manualUploaded bySerrot Onaivlis
- Fuzzy-based algorithm for color recognition of license plates.pdfUploaded bypetacacas
- Homework MatlabUploaded byMahmoud Basho
- matlabUploaded byPrashantyelekar
- Crowd Monitoring Using Image Processing_1995Uploaded bytigerwml
- MATLAB TutorialUploaded byYasir Jamal Ghauri

- Visible Light Induced Cytotoxicity of Curcumin and Its Iron III ComplexUploaded byAmiliya Emil
- PerKBPOM No 7 Tahun 2014Uploaded byIwan Susanto
- Mathylene Blue Curcumin and Ion Pairing Nanoparticles Effects on PDT of MDA MB 231 Breast Cancer CellUploaded byAmiliya Emil
- 2577-1-3435-1-10-20121113Uploaded byAmiliya Emil
- 1-s2.0-S1876619615000108-mainUploaded byAmiliya Emil
- G17raaUploaded byAmiliya Emil
- PVA dengan Metode Electrospinning.pdfUploaded byNonong Isdayanti
- penetrasi kulitUploaded byNovitra Dewi
- 03.016.00 ImunofluorosesnseUploaded byAmiliya Emil
- Bf 00306012Uploaded byAmiliya Emil
- Use Curcuma Longa in Cosmatic in Vitro Skin Permeation StudiesUploaded byAmiliya Emil
- 2657-6569-1-SMUploaded byAmiliya Emil
- 77263523-Image-Thresholding-Using-Otsu.pdfUploaded byAmiliya Emil
- buat bab 3Uploaded byramen910
- Perancangan Konstruksi Turbin Angin di Atas.pdfUploaded byAmiliya Emil
- nanomaterials-05-02302Uploaded byAmiliya Emil
- jmdh-6-281.pdfUploaded byAmiliya Emil
- Sistem Deteksi Penyusup Dengan Sinar LaserUploaded byAmiliya Emil
- Extraction of Curcumin.pdfUploaded byFranz Wensten
- Pematangan Cervix Cervical Ripening Pada Persalinan Preterm Peran Interluekin 8Uploaded byAmiliya Emil
- crivello2005Uploaded byAmiliya Emil
- Anatomi Dan Fisiologi Jantung Dan Pembuluh DarahUploaded byDewi Widyaningsih
- 36_35Uploaded byAmiliya Emil
- LAPORAN PRAKTIKUM ISOLASI KURKUMIN dan DERIVATNYA dari KUNYIT.pdfUploaded byNahri Azizah

- Rudder Prepared by SafkatUploaded bySafkat Jubaer Shuvo
- Thesis Van Ende FinalUploaded byArtem Kravchenko
- Sistema Acometidas ResidencialUploaded byNiconi1515
- Libro de Rodaje CompletoUploaded bycheski85
- CASO 1.Wang LaboratoriesUploaded byAndrue Bremenn Tito Torrejón
- a330 Fuel TanksUploaded byknez424
- Pasta1Uploaded byDanilo Menezes
- 0.-Acta de Recepcion-construccion Del Modulo DemostrativoUploaded bylesale
- Indicadores de Gestión 1 Www.cashtrainers.comUploaded byJose Luis Ataulluco
- Fire-Risk-Assessment-and-The-Fire-Safety-Order-Presentation.pdfUploaded byarman_morala
- Apresentação da DisciplinaUploaded byuleonidio
- Progress-Energy-Carolinas-Inc-Seasonal-or-Intermittent-Service/SIUploaded byGenability
- Store KeeperUploaded byLucky Permana
- 03 Contenido Produccion LimpiaUploaded bylilyricardoseaman
- Manual PreziUploaded byGerardo Sanches
- Introduccion camisa y serpentinUploaded byPablo Hernandez
- IT800 User GuideUploaded byMarius Ursache
- Codigo de Normas y Especificaciones TecnicasUploaded byCaterina Villanueva
- Poster-IS Intrinsic safety basicsUploaded bykpmalik6364
- Magura Julie MIOSUploaded bypescatera8
- Midterm1 SampleUploaded byWaleedWael
- Evaluacion de Conductores VolquetaUploaded byIsrael Pérez
- ECE_SAR Part B ECE.pdfUploaded byBharath Gk
- bharath 81-90Uploaded byapi-261501766
- Visi MouldUploaded bySreedhar Pugalendhi
- O PROCESSO PRODUTIVO NA MINERAÇÃO DE AREIA.pdfUploaded byAnonymous fGUP5h2A
- API RP920 Prevention of Brittle Fracture of Pressure Vessels_1990Uploaded byKirubha Venkatesh
- EchoLife HG8240&HG8245&HG8247 GPON Terminal Service Manual-(V100R002C00&C01_04)Uploaded byspamzderac
- Práctica Pérdidas en tuberíasUploaded bymauricio6rubio-4
- ZK 5 Configuration ReferenceUploaded byPavan Kumar