hi..i am writing the code for recursive mean separate histogram equalization..i am getting an error called "Undefined function 'averpixcal' for input arguments of type 'double'."when calling the function 'averpixcal'..code is attached for reference

//----main module-----// PicOri=imread('C:\Users\Public\Pictures\Sample Pictures\image14.jpg'); % if isgray(PicOri)==0 PicGray=rgb2gray(PicOri); % else % PicGray=PicOri; % end figure(1),imshow(PicGray),title('Ô­»Ò¶ÈͼÏñ');
h=imhist(PicGray); % figure(2),plot(h),title('ԭͼÏñÖ±·½Í¼');
[m,n]=size(PicGray); PicHEt=zeros(m,n);
max = double(max(PicGray(:))); min = double(min(PicGray(:)));
r=1; length=2^r; Xm=zeros(1,length); Xm(1)=max+1; Xm(2)=min+1;
for i=1:r for j=1:2^(i-1) Xm(2^(i-1)+j+1)= averpixcal(h,Xm(2^(i-1)-j+2),Xm(2^(i-1)-j+1)); end Xm=sort(Xm,'descend'); end Xm=sort(Xm);
for i=2:2^r [row,col]=find((PicGray>=Xm(i-1)-1)&(PicGray<=Xm(i)-2)); PicHEt=FuncHE(PicGray,PicHEt,row,col,h,Xm(i-1)-1,Xm(i)-2,m,n); end [row,col]=find((PicGray>=Xm(2^r)-1)&(PicGray<=Xm(2^r+1)-1)); PicHEt=FuncHE(PicGray,PicHEt,row,col,h,Xm(2^r)-1,Xm(2^r+1)-1,m,n);
PicHE=uint8(PicHEt); h1=imhist(PicHE); figure(3),imshow(PicHE),title('¾ùºâºóµÄͼÏñ'); figure(4),plot(h1),title('¾ùºâºóµÄÖ±·½Í¼'); ---------------------------------------------------------------------------------
//---function averpixcal----// function Xm=averpixcal(h,begin,ending)
PixSum=0; Sum=0; for i=begin:ending PixSum=(i-1)*h(i)+PixSum; Sum=h(i)+Sum; end Xm= double(round(PixSum/Sum)) -----------------------------------------------------------------------------------
//-----function to find the histogram equalization-------// function PicHEt=FuncHE(PicGray,PicHEt,row,col,h,min,max,m,n)
pix=size(col,1);
%PZ=zeros(1,Xm(2)-1); PZ=zeros(1,max-min+1);
for i=min+1:max+1 PZ(i-min)=h(i)/pix; end
%S=zeros(1,Xm(2)-1); S=zeros(1,max+1);
S(min+1)=PZ(1); for i=min+2:max+1 S(i)=PZ(i-min)+S(i-1); end
FuncHE=min+(max-min)*S;
for k=1:pix PicHEt(row(k),col(k))=floor(FuncHE(PicGray(row(k),col(k))+1)); end

답변 (2개)

Mischa Kim
Mischa Kim 2014년 2월 13일
편집: Mischa Kim 2014년 2월 13일
Vishwas, a couple of thoughts:
  • Comments in MATLAB appear after percent symbols. E.g., % This is a comment
  • Is the code you show contained within one function file? Make sure that the functions are in the MATLAB path using the which command in the MATLAB prompt:
>> which averpixcal % in case the function is located in a separate function file
  • Please edit your question for better readability.

댓글 수: 4

hi kim... 1)the three functions are located in three different files.. 2)then the instructions after the comment symbol are intentionally added to check for the correctness of the code...the are not needed in the code...
OK. Then I suggest that you move all function files into the same folder and then make this folder the current MATLAB folder:
Hi, Check out the attached files, Now code is perfectly running. Simply Run reswhe_test.m and select any image. Enjoy! :)

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

Amini
Amini 2014년 11월 5일
please put the full code here , i really need it.
thanks

카테고리

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

질문:

2014년 2월 13일

댓글:

2019년 8월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by