이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)