




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、.三.主程序:function varargout = yasuo(varargin)if nargin = 0 % fig = openfig(mfilename,'reuse');handles = guihandles(fig);guidata(fig, handles);if nargout > 0varargout1 = fig;endelseif ischar(varargin1) tryif (nargout)varargout1:nargout = feval(varargin:); elsefeval(varargin:); % FEVAL switch
2、yardendcatchdisp(lasterr);endend % -function varargout = pushbutton1_Callback(h, eventdata, handles, varargin) img=imread('lena.bmp'); img=im2double(img); img2=blkproc(img,16 16,'walsh(x)'); fileid=fopen('img.dat','w');fileid2=fopen('data.dat','w');fil
3、edata=0;filescaledata=0; subplot(findobj('tag','axes1'); imshow(img);axis off; title('原圖'); lut=8 8 8 8 8 8 8 8 4 4 4 4 4 4 4 4 8 8 4 4 4 4 4 4 4 4 2 2 2 2 2 2 8 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 8 4 4 4 2 2 2 2 2 2 2 2 0 0 0 0 8 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 8 4 4 2 0 0 0 0 0 0
4、0 0 0 0 0 0 8 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 8 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 04
5、 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0; for i=1:16, for j=1:16, if lut(i,j)=0, subdata,subscale=quantizing(img2,lut(i,j),i,j); filedata=filedata,subdata; filescaledata=filescaledata,subscale; end endend filedata=filedata(2:length(filedata); filescaledata=filescaledata(2:length(filescaledata);fwrite(fileid,f
6、iledata,'ubit1');fwrite(fileid2,filescaledata,'double');fclose(fileid); set(findobj('tag','text2'),'string',256/50); % -function varargout = pushbutton2_Callback(h, eventdata, handles, varargin)img=im2double(imread('lena.bmp'); fileid=fopen('img.da
7、t','r'); fileid2=fopen('data.dat','r');filescaledata=fread(fileid2,'double');filedata=fread(fileid,'ubit1');filedata=filedata'filescaledata=filescaledata'filedata=double(filedata);img3=zeros(512);offset1=0;offset2=0;m=0;lut=8 8 8 8 8 8 8 8 4 4 4 4
8、4 4 4 4 8 8 4 4 4 4 4 4 4 4 2 2 2 2 2 2 8 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 8 4 4 4 2 2 2 2 2 2 2 2 0 0 0 0 8 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 8 4 4 2 0 0 0 0 0 0 0 0 0 0 0 08 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 8 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 2 0 0 0 0 0 0 0 0 0 0 0 04 4 4 2 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2
9、2 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0;for i=1:16, for j=1:16, if lut(i,j)=0, img3=dequantizing(img3,filedata,filescaledata,lut(i,j),i,j,offset1,offset2)
10、; m=m+1; offset1=offset1+1024*lut(i,j); offset2=2*m; end endend img4=blkproc(img3,16 16,'dewalsh(x)');fclose(fileid);fclose(fileid2); subplot(findobj('tag','axes2');imshow(img4);axis off;title('壓縮圖像'); error=(img-img4).2; MSE=sum(error(:)/sum(img(:).2); SNR=-10*log10(
11、MSE); set(findobj('tag','text4'),'string',SNR);% -function varargout = pushbutton3_Callback(h, eventdata, handles, varargin)clear;close('yasuo'); 三實(shí)驗(yàn)程序function varargout = xu3(varargin)if nargin = 0 fig = openfig(mfilename,'reuse'); set(fig,'Color',get
12、(0,'defaultUicontrolBackgroundColor'); handles = guihandles(fig); guidata(fig, handles); if nargout > 0 varargout1 = fig; endelseif ischar(varargin1) try if (nargout)varargout1:nargout = feval(varargin:); elsefeval(varargin:); end catch disp(lasterr); endend% -function varargout = pushbut
13、ton1_Callback(h, eventdata, handles, varargin)lena=imread('lena.bmp');lena=im2double(lena);%mohu%for i=1:512 for j=1:512 if i=1|i=512|j=1|j=512 lena1(i,j)=0; else lena1(i,j)=lena(i+1,j)+lena(i-1,j)+lena(i,j+1)+lena(i,j-1)-4*lena(i,j); end endendlena2=0.05*lena1+lena;%tidu%for i=1:512 for j=1
14、:512 if i=1|i=512|j=1|j=512 lena3(i,j)=0; elseif sqrt(lena2(i,j)-lena2(i+1,j)2+(lena2(i,j)-lena2(i,j+1)2)>=512 lena3(i,j)=512; else lena3(i,j)=sqrt(lena2(i,j)-lena2(i+1,j)2+(lena2(i,j)-lena2(i,j+1)2); end endendlena3=lena-lena3;%laplace%for i=1:512 for j=1:512 if i=1|i=512|j=1|j=512 lena4(i,j)=0;
15、 else lena4(i,j)=lena2(i+1,j)+lena2(i-1,j)+lena2(i,j+1)+lena2(i,j-1)-4*lena2(i,j); end endendlena4=lena-lena4; subplot(2,2,1);imshow(lena);title('原始圖像'); subplot(2,2,2);imshow(lena2);title('模糊圖像'); subplot(2,2,3);imshow(lena3);title('梯度銳化圖像'); subplot(2,2,4);imshow(lena4);tit
16、le('拉普拉斯銳化圖像');三源程序:% -function varargout = pushbutton2_Callback(h, eventdata, handles, varargin)%復(fù)原clear;f1=zeros(256,256);f2=zeros(256,256);gf=zeros(256,256);h=zeros(256,256);h2=zeros(256,256);f=zeros(256,256);ff2=zeros(256,256);p1=0;p2=0;g=im2double(imread('peppers_degraded.tif');
17、f=im2double(imread('peppers.tif');gf=fft2(g);for i=1:256 for j=1:256 h(i,j)=(1/(1+(i-129)2+(j-129)2)/362)5); endend%反向?yàn)V波for i=1:256 for j=1:256 ff(i,j)=1/2562*gf(i,j)/h(i,j); endendf1=ifft2(ff)/max(max(ifft2(ff);%維納濾波gf=fftshift(gf);for i=1:256 for j=1:256 ff2(i,j)=gf(i,j)*(1/h(i,j)*(abs(h(i
18、,j)2/(abs(h(i,j)2+17); endendf2=ifft2(fftshift(ff2)/max(max(ifft2(fftshift(ff2);h2=ff2./gf;%求峰值信噪比for i=1:256 for j=1:256 p1=(g(i,j)-f1(i,j)2+p1; p2=(g(i,j)-f2(i,j)2+p2; endendpmse1=-10*log10(1/2562*p1/double(max(max(g)2)pmse2=-10*log10(1/2562*p2/double(max(max(g)2)subplot(2,2,1)imshow(f)subplot(2,2
19、,2)imshow(g)subplot(2,2,3)imshow(abs(f1)subplot(2,2,4)imshow(abs(f2)% -function varargout = pushbutton4_Callback(h, eventdata, handles, varargin)%邊沿檢測(cè)clear;f=double(imread('lena.bmp');f1=zeros(512,512);f2=zeros(512,512);f3=zeros(512,512);for i=2:511 for j=2:511 f1(i,j)=(sqrt(f(i,j)-f(i-1,j-1
20、)2+(f(i-1,j)-f(i,j-1)2); f3(i,j)=(abs(f(i+1,j)+f(i-1,j)+f(i,j+1)+f(i,j-1)-4*f(i,j); f2(i,j)=(sqrt(f(i-1,j+1)+2*f(i,j+1)+f(i+1,j+1)-(f(i-1,j-1)+2*f(i,j-1)+f(i+1,j-1)2+(f(i-1,j-1)+2*f(i-1,j)+f(i-1,j+1)-(f(i+1,j-1)+2*f(i+1,j)+f(i+1,j+1)2); endendf1=uint8(f1);f2=uint8(f2);f3=uint8(f3);f=uint8(f);figurei
21、mshow(f)title('原圖')figureimshow(f1)title('robert');figureimshow(f2)title('sobol')figureimshow(f3)title('laplacian')% -function varargout = pushbutton5_Callback(h, eventdata, handles, varargin)%銳化clear;f=double(imread('lena.bmp');f1=zeros(512,512);f1=f;f3=zeros
22、(512,512);for i=2:511 for j=2:511 if (sqrt(f(i,j)-f(i+1,j+1)2+(f(i+1,j)-f(i,j+1)2)>50 f1(i,j)=(sqrt(f(i,j)-f(i+1,j+1)2+(f(i+1,j)-f(i,j+1)2); end f3(i,j)=(abs(f(i+1,j)+f(i-1,j)+f(i,j+1)+f(i,j-1)-4*f(i,j); endendfigureimshow(uint8(f)title('原圖')figureimshow(uint8(f1)title('robert');f
23、igureimshow(uint8(f-f3)title('laplacian')% -function varargout = figure1_ButtonDownFcn(h, eventdata, handles, varargin)% -function varargout = pushbutton1_Callback(h, eventdata, handles, varargin三實(shí)驗(yàn)程序:% 用Robert算子邊緣檢測(cè)clear;img=imread('lena.bmp');img=double(img);a1=-1,0;0,1;a2=0,-1;1,0;z1=conv2(img,a1,'same');z2=conv2(img,a2,'same');r=sqrt(z1.2+z2.2);r=uint8(r);imwrite(r,'robert.bmp');subplot(1,1,1);imshow(r);title('robert算子檢測(cè)');% 用Sobel算子邊緣檢測(cè)clear;img=imread('lena
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 檢驗(yàn)科室承包合同
- 建筑工程施工合同書合同
- 房屋買賣按揭合同書
- 工業(yè)品買賣合同經(jīng)典
- 交通標(biāo)牌采購(gòu)?fù)稑?biāo)合同
- 存量房買賣房屋租賃合同出租
- 非公開協(xié)議合同
- 鮮奶代加工合同協(xié)議書
- 挖機(jī)按天施工合同協(xié)議書
- 公司直播協(xié)議合同
- SAP-TM運(yùn)輸管理模塊操作手冊(cè)(S4系統(tǒng))
- 【醫(yī)療管理案例】:以專科化改革促進(jìn)醫(yī)院戰(zhàn)略發(fā)展-中南大學(xué)湘雅醫(yī)院學(xué)科建設(shè)實(shí)踐案例
- 設(shè)計(jì)研究與人因工程結(jié)合發(fā)展
- DLT448-2000-14執(zhí)行標(biāo)準(zhǔn)與規(guī)范
- 湖北省衛(wèi)生健康委科研項(xiàng)目申報(bào)書(上、下冊(cè))
- 基金應(yīng)知應(yīng)會(huì)專項(xiàng)考試題庫(kù)(證券類190題)附有答案
- 【寶鋼股份環(huán)境會(huì)計(jì)信息披露問題探究6700字(論文)】
- 節(jié)流式差壓流量計(jì)工作原理
- 精神科手衛(wèi)生與患者關(guān)懷
- TD/T 1061-2021 自然資源價(jià)格評(píng)估通則(正式版)
- 2024年新鄉(xiāng)職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)適應(yīng)性測(cè)試題庫(kù)附答案
評(píng)論
0/150
提交評(píng)論