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

조회 수: 7 (최근 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

답변 (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
Suraj Kamya
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! :)

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


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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by