evalfis error

14 views (last 30 days)
mideas
mideas on 3 Apr 2012
hi.. the fuzzy inference system 'a' takes 3 inputs. function RGB2Lab is already defined. the following is the code in which the FIS has to evaluate the l,a,b values of the image.
z=imread('Lenna.png');
x=readfis('a.fis');
s=imresize(z,[128 128]);
R=s(:,:,1);
G=s(:,:,2);
B=s(:,:,3);
[L,a,b]=RGB2Lab(R,G,B);
[m,n]=size(s);
Ld=double(L);
ad=double(a);
bd=double(b);
for i=1:m
for j=1:n
q=evalfis([Ld ad bd],x);
end
end
the error shown is: Error using ==> evalfis The first argument should have as many columns as input variables and as many rows as independent sets of input values.
Error in ==> ch at 22 q=evalfis([Ld ad bd],x);
can anyone please help me correct it..

Accepted Answer

Walter Roberson
Walter Roberson on 3 Apr 2012
We can tell from your extraction of R, G, and B, that s is a 3 dimensional array. Your code line [m,n] = size(s) makes it look like a 2 dimensional array. There is meaning to that line, but it is not to extract just the first and second dimensions: when you use more than one output argument to size() and the number of output arguments is smaller than the number of dimensions, then the last output argument will be given a value which is the product of all the dimensions from there on.
Your nested "for" loops do not change any parameters in the call to evalfis(), so it is not clear why you are bothering to loop.
After your image resize, s will be 128 x 128 x 3 so [Ld ad bd] is going to be 128 x 384 . Is your fis set up to expect 128 input variables?
  3 Comments
Walter Roberson
Walter Roberson on 4 Apr 2012
How many input variables does the FIS expect? Is it intended to process column by column perhaps?
We know from the documentation what evalfis() is supposed to do in general, but we do not know what your a.fis contains so we cannot yet advise on how to modify your code.
mideas
mideas on 4 Apr 2012
the FIS takes 3 input variables.

Sign in to comment.

More Answers (1)

mideas
mideas on 4 Apr 2012
this is my a.fis
[System]
Name='a'
Type='mamdani'
Version=2.0
NumInputs=3
NumOutputs=1
NumRules=26
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
[Input1]
Name='L'
Range=[0 100]
NumMFs=3
MF1='black':'trimf',[0 0 40]
MF2='gray':'trimf',[10 50 90]
MF3='white':'trimf',[60 100 100]
[Input2]
Name='a'
Range=[-86.1813 98.2352]
NumMFs=5
MF1='red':'trimf',[-86.2 -86.2 -29.34]
MF2='greenish':'trimf',[1.46365079365083 44.8636507936508 81.4636507936508]
MF3='green':'trimf',[42.8678835978836 98.6878835978836 98.6878835978836]
MF4='reddish':'trimf',[-69.3 -43.0023015873016 0]
MF5='amiddle':'trimf',[-10 0 10]
[Input3]
Name='b'
Range=[-107.8617 94.4758]
NumMFs=5
MF1='blue':'trimf',[-108 -108 -47.13]
MF2='bmiddle':'trimf',[-10 0 10]
MF3='yellow':'trimf',[33.7124603174603 94.5 95]
MF4='bluish':'trimf',[-86.7518253968254 -50 0]
MF5='yellowish':'trimf',[0 50.3097619047619 74.4]
[Output1]
Name='fuzzyhist'
Range=[0 15]
NumMFs=15
MF1='black':'trapmf',[0 0 0.8 1.2]
MF2='blue':'trapmf',[0.83968253968254 1.23968253968254 1.83968253968254 2.23968253968254]
MF3='yellow':'trapmf',[3.8 4.2 4.8 5.2]
MF4='magenta':'trapmf',[4.8 5.2 5.8 6.2]
MF5='gray':'trapmf',[6.8 7.2 7.8 8.2]
MF6='teal':'trapmf',[8.8 9.2 9.8 10.2]
MF7='violet':'trapmf',[9.8 10.2 10.8 11.2]
MF8='pink':'trapmf',[11.8 12.2 12.8 13.2]
MF9='cyan':'trapmf',[13.8 14.2 15 15]
MF10='navy':'trapmf',[1.8 2.2 2.8 3.2]
MF11='red':'trapmf',[2.8 3.2 3.8 4.2]
MF12='brown':'trapmf',[5.8 6.2 6.8 7.2]
MF13='green':'trapmf',[7.8 8.2 8.8 9.2]
MF14='orange':'trapmf',[10.8 11.2 11.8 12.2]
MF15='white':'trapmf',[12.8 13.2 13.8 14.2]
[Rules]
1 5 2, 1 (1) : 1
2 -3 1, 2 (1) : 1
1 0 4, 2 (1) : 1
3 5 4, 2 (1) : 1
3 2 4, 2 (1) : 1
1 4 1, 10 (1) : 1
2 1 -1, 11 (1) : 1
2 4 2, 11 (1) : 1
1 4 5, 11 (1) : 1
2 4 3, 3 (1) : 1
3 5 3, 3 (1) : 1
3 2 3, 3 (1) : 1
2 4 4, 4 (1) : 1
3 4 4, 4 (1) : 1
2 5 5, 12 (1) : 1
3 4 3, 12 (1) : 1
2 5 2, 5 (1) : 1
2 2 3, 13 (1) : 1
3 3 5, 13 (1) : 1
2 2 2, 6 (1) : 1
2 3 1, 7 (1) : 1
3 1 3, 14 (1) : 1
3 4 2, 8 (1) : 1
3 5 2, 15 (1) : 1
3 2 2, 9 (1) : 1
3 3 4, 9 (1) : 1
  5 Comments
Walter Roberson
Walter Roberson on 4 Apr 2012
After posting I realized I wasn't sure that this was correct. I would need to look further at fis models. Unfortunately that is not something I will have time to do today.
mideas
mideas on 5 Apr 2012
its okay..

Sign in to comment.

Categories

Find more on Fuzzy Logic Toolbox 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!