资源描述:
《图像增强参考程序》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、反色functionInverse_Callback(hObject,eventdata,handles)x=imread('*•bmp')y=255-x;直方图均衡HisteQ_Callback(hObject,eventdata,handles)x=imread(、*•bmp')N=256;[row,col]=size(x);p=zeros(N);fori=l:row*col;p(x(i)+l)=p(x(i)+l)+l;%%%%%%%汁算灰度值为i的个数,类似%%%%%p(i+l)=length(find(x==i))/(m*n);endp=
2、(double(p))/(row*col);fork=2:Np(k)=p(k)+p(k-l);ends=fix(256*p);fori=l:row*col;x(i)=s(x(i)+1)-1;end阈值变换x=imread('*.bmp')prompt={1Threshold(0-255):1};name=1InputforThresholding1;numlines=l;defaultanswer={'501};anss=inputdlg(prompt,name,numlines,defaultanswer);th=str2num(anss{l}
3、);[row,col]=size(x);fori=l:row*col;ifx(i)>thx(i)=256;elseX(i)=0;endend全局线性变换..f=imread(、*.bmpz)[row,col]=size(f);fl=double(f);prompt={1themingraylevelforoutputimage(0-255):11themaxgraylevelforoutputimage(0-255):'};name=1InputforContraststretching';numlines=l;defaultanswer={10
4、112551};anss=inputdig(prompt,name,numlines,defaultanswer);b=str2num(anss{1});a=str2num(anss{2});fminGray=min(min(f1));fmaxGray=max(max(f1));g=double(zeros([row,col]));forx=l:rowfory=l:colg(x,y)=[(a-b)*(f1(x,y)-fminGray)/(fmaxGray-fminGray)]+b;endend分段线性变换...f=imread('*.bmp')[
5、row,col]=size(f);fl=double(f);N=256;prompt={"thexofthefirstpoint:11theyofthefirstpoint:11thexofthesecondpoint:1'theyofthesecondpoint:11themaximumgraylevelforoutputimage:1};name=1InputforContraststretching1;numlines=l;defaultanswer={'801170111701'180r'255'};anss=inputdlg(promp
6、t,name,numlines,defaultanswer);)3})4})xl=str2num(anssyl=str2num(anssx2=str2num(anssy2=str2num(anssgmaxGray=str2num(anss{5})fmaxGray=max(max(f1));forx=l:rowfory=l:coliff1(x,y)<=xlg(x,y)=x2*f1(x,y)/xl;elseif(f1(x,y)>xl)&(f1(x,y)<=x2)g(x,y)=(y2-yl)*(f1(xzy)-xl)/(x2-xl)+yl;elseg(
7、x,y)=(gmaxGray-y2)*(f1(x,y)-x2)/(fmaxGray-x2);endendendend对数非线性变换...f=imread(、★•bmp')[row,col]=size(f);mode.WindowStyle=1modal1;mode.Interpreter:1tex1;msgbox(’g(x,y)=a+(In[f(x,y)+1])/(b*ln(c))1,1theformul1,,mode1);prompt:{1parametera:11parameterb:'1parameterc:1};name=1Inputfo
8、rLOGtranformation1;numlines=l;defaultanswer={'0'111丨10丨};anss=inputd