this program implements a fuzzy color histogram,the fuzzy system a takes 3 inputs.rgb2lab is already defined.the output graph,i.e the histogram plot has 15 bins
z=imread('Lenna.png');
x=readfis('a.fis');
R=z(:,:,1);
G=z(:,:,2);
B=z(:,:,3);
%x1=0:1:15;
[L,a,b]=RGB2Lab(R,G,B);
%L1=cat(3,L,a,b);
%imshow(L1)
[m,n,o]=size(s);
q=[];
%L=zf(:,1);
Ld=double(L);
%L1d=double(L1);
%a=zf(:,2);
ad=double(a);
%b=zf(:,3);
bd=double(b);
for i=1:m
for j=1:n
q(i,j)=evalfis([Ld(i,j) ad(i,j) bd(i,j)],x);
end
end
bar(q(i,j))
i need to plot the output 'q' as a bar graph.and i need the x-range to be in 0-15. but there is an error: rror using ==> bar The length of X must match the number of rows of Y. can anyone help with this?

댓글 수: 1

piyali banerjee
piyali banerjee 2014년 2월 21일
when running this code I am getting q[] values same for all the rows and columns as .5 for any jpg images.Can anybody tell me which portion of the code should I modify to get the correct result aswellas correct bar chart?

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 7일

0 개 추천

You have a nested for loop over i and j. After the end of that loop, you ask to bar(q(i,j)) . That is asking to create a bar plot of the single value stored at q(i,j) based upon the values of i and j after the "for" loops. MATLAB leaves the loop variable in a "for" loop set to the last valid value, so this will be q(m,n) that you are asking to create a bar plot of.
Considering that q is 2 dimensional, it is not at all clear what you are wanting to create a bar plot of. Especially as, in past threads, you have indicated that what evalfis() on your particular FIS returns is already the histogram, rather than a histogram bin number.
If I were to guess, I would say that what you want is
hist(q(:))

댓글 수: 6

mideas
mideas 2012년 4월 8일
The FIS returns the histogram values. N i want to plot those values as a bar graph.
And hist(q(:)) gives error. Thanx anyways.
Walter Roberson
Walter Roberson 2012년 4월 8일
Is the error you get for hist(q(:)) the same as you reported earlier, "The length of X must match the number of rows of Y" ? If so then you either have a corrupted version of bar(), or else (more likely) you have accidentally named one of your own .m files with the name of a routine that bar() calls upon for its computations.
Note: considering the range of values you want, I should have said to use
hist(q(:), 16)
That would only change the visible output though, and will not in itself fix any problem with bar()
I suggest that at the command line, you command
dbstop in bar
and then run the hist(q(:),16) . When it stops in bar.m, step through line by line to see which routines are being called, and make sure that you do not have any .m routines of your own with the same name.
mideas
mideas 2012년 4월 8일
this is the error that is shown( for hist(q(:)) and hist(q(:),16) ):-
Error using ==> mtimes
Integers can only be combined with integers of the same class, or scalar doubles.
Error in ==> hist at 63
xx = miny + binwidth*(0:x);
And i dont have any .m routines with the same name.
Walter Roberson
Walter Roberson 2012년 4월 8일
Hmmm... try hist(double(q(:)),16)
mideas
mideas 2012년 4월 9일
i think its working now.. thanx a lot!
piyali banerjee
piyali banerjee 2014년 2월 21일
I am getting all the q(m,n) values as .5 taking any images as consideration.Can anyone solve the problem?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품

질문:

2012년 4월 7일

댓글:

2014년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by