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
Afficher commentaires plus anciens
//----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
1 commentaire
Image Analyst
le 13 Fév 2014
You forgot to attach image14.jpg so we can run your code.
Réponses (2)
Mischa Kim
le 13 Fév 2014
Modifié(e) : Mischa Kim
le 13 Fév 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 commentaires
vishwas h s
le 13 Fév 2014
Mischa Kim
le 13 Fév 2014
Modifié(e) : Mischa Kim
le 13 Fév 2014
OK. Then I suggest that you move all function files into the same folder and then make this folder the current MATLAB folder:

Suraj Kamya
le 16 Avr 2014
Hi, Check out the attached files, Now code is perfectly running. Simply Run reswhe_test.m and select any image. Enjoy! :)
shawana khan
le 16 Août 2019
thanks
Amini
le 5 Nov 2014
0 votes
please put the full code here , i really need it.
thanks
1 commentaire
shawana khan
le 16 Août 2019
upper code is full suraj qumar gave it
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!