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

1 view (last 30 days)
//----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

Answers (2)

Mischa Kim
Mischa Kim on 13 Feb 2014
Edited: Mischa Kim on 13 Feb 2014
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 Comments

Sign in to comment.


Amini
Amini on 5 Nov 2014
please put the full code here , i really need it.
thanks

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!