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 回表示 (過去 30 日間)
古いコメントを表示
//----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 件のコメント
回答 (2 件)
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 件のコメント
Suraj Kamya
2014 年 4 月 16 日
Hi, Check out the attached files, Now code is perfectly running. Simply Run reswhe_test.m and select any image. Enjoy! :)
参考
カテゴリ
Help Center および File Exchange で Switches and Breakers についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!