Problem with defuzz method

1 view (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)

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!