現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
use evalfis to read input under a range
3 ビュー (過去 30 日間)
古いコメントを表示
leow
2013 年 8 月 9 日
Hi,
May i know is there any coding can can be use for evalfis to read input under range or not? For my case:
A=imread('Linggi.tif');
[m n p]=size(A)
r=A(:,:,1);
g=A(:,:,2);
b=A(:,:,3);
Y=readfis('mam.fis');
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?
6 件のコメント
leow
2013 年 8 月 10 日
Hi,
May I know is that the value under evalfis([ eg },Y), for the eg part, is that necessary for me to put number? Can i put range?
Thanks.
Iman Ansari
2013 年 8 月 10 日
Hi. I don't understand what you want to do but:
Output = zeros(size(r));
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);
Output(i,j) = evalfis([k1 l1 z1],Y);
end
end
% or
k= r > 88 & r <= 90;
l= g > 134 & g <= 140;
z= b > 144 & b <= 145;
k1=double(k);
l1=double(l);
z1=double(z);
Output = evalfis([k1(:) l1(:) z1(:)],Y);
Output = reshape(Output,[m n]);
leow
2013 年 8 月 10 日
Hi,
Actually what i want to do is to let the inference system automatic justify the output classes based on the input range such as k, l and z. The coding is worked out, however, the output answer for all the output it run appears the same answer. Therefore, I want want to ask, for my case, is that the problem of output value are all the same is because of my inference system built wrong already?
Thanks.
Iman Ansari
2013 年 8 月 10 日
編集済み: Iman Ansari
2013 年 8 月 10 日
Why your inputs are logical or zero and one? Check your fuzzy system in Rule Viewer:
Y = readfis('mam.fis');
ruleview(Y)
you can enter your inputs in the lower left of the rule viewer window in the input box then press enter:
[0 0 0]
[0 1 0]
[0 0 1]
leow
2013 年 8 月 10 日
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
2013 年 8 月 10 日
編集済み: Iman Ansari
2013 年 8 月 10 日
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;
A=imread('Linggi.tif');
[m n p]=size(A);
r=A(:,:,1);
g=A(:,:,2);
b=A(:,:,3);
Y=readfis('mam.fis');
Mask = r > 88 & r <= 90 & g > 134 & g <= 140 & b > 144 & b <= 145;
k1=r(Mask);
l1=g(Mask);
z1=b(Mask);
Output = evalfis([k1 l1 z1],Y);
Result = A;
Result(Mask) = Output;
19 件のコメント
leow
2013 年 8 月 10 日
Hi,
I have try out the coding but it shows out error of ??? Error using ==> evalfismex The first input must be a defined DOUBLE matrix
Error in ==> evalfis at 84
[output,IRR,ORR,ARR] = evalfismex(input, fis, numofpoints);
Error in ==> test at 11
Output = evalfis([k1 l1 z1],Y);
Is that I need to convert k1 l1 and z1 to double?
Thanks.
Iman Ansari
2013 年 8 月 10 日
clear;
A1=imread('Linggi.tif');
A = double(A1);
[m n p]=size(A);
r=A(:,:,1);
g=A(:,:,2);
b=A(:,:,3);
Y=readfis('mam.fis');
Mask = r > 88 & r <= 90 & g > 134 & g <= 140 & b > 144 & b <= 145;
k1=r(Mask);
l1=g(Mask);
z1=b(Mask);
Output = evalfis([k1 l1 z1],Y);
Result = A1;
Result(Mask) = Output;
leow
2013 年 8 月 10 日
Hi,
Thanks, the coding is work. By the way, is there any coding that I can use to know which value of k1,l1 and z1 that the inference system selected to evaluate the output?
Thanks
leow
2013 年 8 月 10 日
Hi,
Thanks, I now can find out the input value and the output value already. Really helps a lot. I use [k1 l1 z1 Output] to display out the input and output value. Actually I have another question. For now, the value of input and output can be show out already, can I know is there any coding that can be use to show out the image of the based on the different value of output that the inference system evaluate?
Thanks.
leow
2013 年 8 月 10 日
Hi,
What I mean is, now the value of k1,l1 and z1 together with output are display out already. However, can I find back the location of the pixel which have the 3 input value that selected by inference system, and show out the output by color regarding to different type of classes that I set? For example, my output value is from 0.5 to 6.5, i want to put under a set of output range which contain 0.5-1.5 , 1.5-2.5 , 2.5-3.5 , 3.5-4.5 , 4.5-5.5 , 5.5-6.5 . I want to show out the image which contain different color based on different output range and display on the pixel of the image. Like that can understand what I want to ask about ?
Iman Ansari
2013 年 8 月 10 日
clear;
Output = rand(10,10).*6 + 0.5;
imshow(Output,[],'InitialMagnification','fit')
colormap('jet')
Or you can code it like this:
clear;
m = randi([0 4],50,50);
[M,N]=size(m);
n = 1;
C = cell(size(m));
C(m==0) = {cat(3,zeros(n),zeros(n),zeros(n))};
C(m==1) = {cat(3,zeros(n),ones(n),zeros(n))};
C(m==2) = {cat(3,ones(n),ones(n),zeros(n))};
C(m==3) = {cat(3,ones(n),zeros(n),zeros(n))};
C(m>3) = {cat(3,ones(n),ones(n),ones(n))};
img = cell2mat(C);
imshow(img,'InitialMagnification','fit');
% set(gca,'XTick',(1:n:size(img,1))-0.5)
% set(gca,'YTick',(1:n:size(img,2))-0.5)
% set(gca,'XTickLabel','')
% set(gca,'YTickLabel','')
% grid on
% set(gca, 'GridLineStyle', '-');
% axis on
leow
2013 年 8 月 11 日
Hi,
I have try to run the coding, I find out that that size of the image has change which becomes bigger already. Is there any way for the image display maintain the original size image?
Thanks.
Iman Ansari
2013 年 8 月 11 日
Output = evalfis([k1 l1 z1],Y);
New_Image = zeros(size(Mask));
New_Image(Mask) = Output;
leow
2013 年 8 月 11 日
Hi,
Is this coding applied on the output image? Because actually what I want to do is, based on the output range that undergoes after the inference system, the original image,A1, the pixel is classify out by different color according to different output range that it belongs to. Is there any coding that can be use to do for that part? for example, the pixel that contain output value from 0.5 to 1.5 in image A1 can be display by red color in the new figure image display.
Thanks.
Iman Ansari
2013 年 8 月 11 日
clear;
A1=imread('Linggi.tif');
A = double(A1);
[m n p]=size(A);
r=A(:,:,1);
g=A(:,:,2);
b=A(:,:,3);
Y=readfis('mam.fis');
Mask = r > 88 & r <= 90 & g > 134 & g <= 140 & b > 144 & b <= 145;
k1=r(Mask);
l1=g(Mask);
z1=b(Mask);
Output = evalfis([k1 l1 z1],Y);
im = zeros(size(Mask));
im(Mask) = Output;
[M,N]=size(im);
C = mat2cell(A1,ones(1,M),ones(1,N),3);
C(im>=0.5 & im<1.5) = {uint8(cat(3,255,0,0))};
img = cell2mat(C);
imshow(img,'InitialMagnification','fit');
leow
2013 年 8 月 11 日
Hi, May I know what did the coding of C = mat2cell(A1,ones(1,M),ones(1,N),3); and {uint8(cat(3,255,0,0))} refers to? Can you explain me about these two coding? Thanks.
Iman Ansari
2013 年 8 月 11 日
編集済み: Iman Ansari
2013 年 8 月 11 日
Image A1 converts to cell array C, in each cell of C puts one of the image pixel values (red,green and blue components means each cell is 1x1x3).
{uint8(cat(3,255,0,0))}
Concatenate these three number in third dimension, then convert it to uint8.
leow
2013 年 8 月 11 日
Hi,
Ok,I understand the coding already. By referring to your coding, the output range 0.5-1.5 are display as red. I try to add other range C(im>=1.5 & im<2.5) = {uint8(cat(3,255,255,0))}; but the image did not display out for two color, it only appear red color only, is that i still need to edit other part of coding?
Thanks
Iman Ansari
2013 年 8 月 11 日
No, I checked it with some random inputs:
clear;
A1 = uint8(zeros(10,10,3));
Mask = logical(randi([0 1],10,10));
Output = rand(nnz(Mask),1)*6.5;
im = zeros(size(Mask));
im(Mask) = Output;
[M,N]=size(im);
C = mat2cell(A1,ones(1,M),ones(1,N),3);
C(im>=0.5 & im<1.5) = {uint8(cat(3,255,0,0))};
C(im>=1.5 & im<2.5) = {uint8(cat(3,255,255,0))};
C(im>=2.5 & im<3.5) = {uint8(cat(3,255,0,255))};
C(im>=3.5 & im<4.5) = {uint8(cat(3,0,0,255))};
C(im>=4.5 & im<5.5) = {uint8(cat(3,0,255,255))};
C(im>=5.5 & im<6.5) = {uint8(cat(3,0,255,0))};
img = cell2mat(C);
imshow(img,'InitialMagnification','fit');
leow
2013 年 8 月 11 日
Hi, May I know why need to use code of A1 = uint8(zeros(10,10,3));? Is that to clear the initial pixel value of the image? What did the code of Mask = logical(randi([0 1],10,10)); and Output = rand(nnz(Mask),1)*6.5; means?
Iman Ansari
2013 年 8 月 11 日
編集済み: Iman Ansari
2013 年 8 月 11 日
I used these 3 lines for testing the code, you don't need these lines.
A1 = uint8(zeros(10,10,3));
Mask = logical(randi([0 1],10,10));
Output = rand(nnz(Mask),1)*6.5;
leow
2013 年 8 月 11 日
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing and Computer Vision についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)