Clear Filters
Clear Filters

Problem with defuzz method

2 views (last 30 days)
Dani D
Dani D on 5 May 2016
Hello, I have an image and fuzification with one triangular membership function. Now i just defuzzy with 'centroid' . but i have an error. Please help me
clc ; clear all, close all;
img = imread('cameraman.tif');
mean_input = mean2(uint8(img));
img = double(img);
[m,n]= size(img);
mu = zeros(m,n);
a = 60 ;
a = double(a);
b = 120 ;
b = double(b);
c = 180;
c = double(c);
for i =1:m
for j=1:n
if img(i,j) <= 0
mu(i,j) = 0;
elseif img(i,j) >= a && img(i,j) <=b
mu(i,j) =(img(i,j)-a)/(b-a);
elseif img(i,j) >= b && img(i,j)
mu(i,j) = (c-img(i,j))/(c - b);
elseif c<=img(i,j)
mu(i,j) = 0;
end
end
end
for i=1:m
for j=1:n
out(i,j) = defuzz(img(i,j),mu(i,j),'centroid');
end
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!