# use evalfis to read input under a range

3 views (last 30 days)
leow on 9 Aug 2013
Hi,
May i know is there any coding can can be use for evalfis to read input under range or not? For my case:
[m n p]=size(A)
r=A(:,:,1);
g=A(:,:,2);
b=A(:,:,3);
for i = 1:m,
for j = 1:n,
k=r(i,j) > 88 & r(i,j) <= 90;
l=g(i,j) > 134 & g(i,j) <= 140;
z=b(i,j) > 144 & b(i,j) <= 145;
k1=double(k);
l1=double(l);
z1=double(z);
evalfis([k1 l1 z1],Y)
end
end
I find out that the output for all the row and column read are the same, which means the inference system did not run for the input.
Is that got another method of evalfis can be use for me to use to read input that contains range?
leow on 10 Aug 2013
Hi,
I put the input as k1(:) l1(:) z1(:). Is that i cannot use that as input although I already declare the value of input by range in k1,l1 and z1 form? I have try to put input through and the output value can be show out. I have input [88 134 144] and it successfully show out the value. If like that, why when using ruleview the output can be show out but when i run the coding the output value only shows out the same value as when i open ruleviewer? Is that mean my input did not pass through the rule that i have been built up?
Thanks.

Iman Ansari on 10 Aug 2013
Edited: Iman Ansari on 10 Aug 2013
In your code, input isn't same as [88 134 144]. They are logical (0,1):
evalfis([88 134 144])
but:
evalfis([0 1 1])
Maybe, this is what you want:
clear;
[m n p]=size(A);
r=A(:,:,1);
g=A(:,:,2);
b=A(:,:,3);
Mask = r > 88 & r <= 90 & g > 134 & g <= 140 & b > 144 & b <= 145;
Output = evalfis([k1 l1 z1],Y);
Result = A;
leow on 11 Aug 2013
Hi, Thanks, the image can display out different color at different output range already. If I want to input other range, mask1=r > 928 & r <= 100 & g > 147 & g <= 150 & b > 134 & b <= 150; and the result use the same output range that set before to display different color for different range, the part of k1=r(Mask); l1=g(Mask); z1=b(Mask); and im(Mask) = Output; how to edit?
Thanks.

### Community Treasure Hunt

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

Start Hunting!

Translated by