DigitalImageProcessHomeWork 2課件_第1頁
DigitalImageProcessHomeWork 2課件_第2頁
DigitalImageProcessHomeWork 2課件_第3頁
DigitalImageProcessHomeWork 2課件_第4頁
DigitalImageProcessHomeWork 2課件_第5頁
已閱讀5頁,還剩55頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、Homework Assignment#2數(shù)位影像處理Digital Image Processing目 錄Home Work Assignment #220.My homework program usage and introduction:21.Programming Discrete Fourier Transform (DFT), Inverse Discrete32.Programming Laplacian-Based Enhancement:73.MATLAB source code of my program12Home Work Assignment #20. My hom

2、ework program usage and introduction:l Program outline:l Operation methods: Use MATALAB 7.0 to open the source code named “HW2.m” in “DIP94318522HW2.rar” (“HW2.fig should included) unzipped folder and to copy all the images files to your c: or change above path of the image files and click right but

3、tons to get the result.l The computer that I used to run the program is P4 - 3.06 G with 760MB RAM installed.1. Programming Discrete Fourier Transform (DFT), Inverse DiscreteFourier Transform (IDFT), Fast Discrete Fourier Transform (FFT) andInverse Fast Discrete Fourier Transform (IFFT):(1) Take DFT

4、 and IDFT for both “Lena image” and your own image plied first.According to the results, please discuss the different between originalimages and the images after DFT and IDFT.(2) Take FFT and IFFT for both “Lena image” and your own image plied first.According to the results, please discuss the diffe

5、rent between originalimages and the images after DFT and IDFT.(3) Please compare the computed time when the resolution of the aboveimages change. You should compare 6 different resolution at least.Sol: Solution (1-1):Since DFT is quite consume the resource of computer so I select the small size of i

6、mages as the problem target. Lina40.jpg and Myson40.jpg s all 40x40 image, by the way I noticed that not symmetry array will use more computer resource and making my computer unstable and hard to gain the result, after resize all the image to symmetry ones, the computer unstable problem is disappear

7、.Any way the small size images are hard to see its detail even you zoom-in it, the resolution still very bad. You can use FFT in much bigger images and you will see the result detail in very short time or you can find the detail in my solution of problem 1-2 that in afterward section.The result also

8、 presented that use the same image to perform the DFT and IDFT, the result is the same that also prove that the DFT and inverse DFT is a pair.Solution (1-2):In the next page you will see 2 result of problem 1-2, one is using the small size images and the other one is the bigger images for FFT and In

9、verse FFT. Actually I cant sense the time different that used by my PC for small images and big images but if I use DFT and inverse DFT, its will take much long time (It is impossible for my pc as I think, since I ever waited couple hours) to wait for the result come out.The images of FFT and DFFT a

10、re the same and timed with different constant in order to enhance the center parts of the images and you can find it in source-code that attached in the end of my homework2. I also noticed that the Lena picture width is look smaller than myson picture so the frequency domain picture of Lena is wider

11、 than myson and it also present the FFT & IFFT character that teacher told us in the class. Solution (1-3):Here I need to follow teachers order to compare 6 time-different between different resolution images of FFT transfer and DFT transfer, since DFT still quite consume my pc resource so still use

12、6 small size of images for comparison and the result as below. You can fine the FFT used time almost zero but the DFT. And the difference will be increased lots when the image size increased a little.All the images are symmetry images as its filename presented e.g. lina70.jpg is a 70x70 pixels image

13、.P.S. The time unit that used for above testing is second and the time was calculated by the program, you will find it in my source code afterward as well.Images output as below for problem 1-3 as below.2. Programming Laplacian-Based Enhancement:(1) Take Laplacian-Based Enhancement for both “Lena im

14、age” and your ownimage by spatial filtering approach. According to the results, please giveyour comment.(2) Take Laplacian-Based Enhancement for both “Lena image” and your ownimage by frequency-domain approach. Comparing the results with problem (1).Sol: Solution (2-1):According to books mentioned t

15、hat the Laplacian-Based enhancement will improve the clearance of image, form the result images that in next page that some detail of the images seems look more clear than before (e.g. Lenas hair line parts that in the middle of the image), but any way with out any further image processing, the cont

16、rast of the images is not as good as before and that what I found. Solution (2-2):The Laplacian-Based enhancement that working un frequency domain of the images are been shown in the next page, from the result I found that the image after inverse FFT is distorted compared to the problem 2-2 result,

17、I think this is wraparound error effect. Since I used moon.jpg to do the enhancement as below and I could see the warparound error on it in the left and down side of the image. So I did some improvement in the image2 (my own image) enhancement by padding zeros to the image and see weather the wrapar

18、ound error will disappear or not, but I found that the distortion condition is improved lot but seems not very good. Imae1 before Padding:And if I set the F(1,1) LAPLACIAN(1,1)= -50000000000000000000 then IFFT image1 and it will looked like as below. But I can see cross noise in the image.Image1 aft

19、er padding:.The cross noise seems to be improvedImage 2 after padding:And if I set the F(1,1) LAPLACIAN(1,1)= -50000000000000000000 then IFFT image2 and it will looked like as below.Image2 before padding:Set the F(1,1) LAPLACIAN(1,1)= -50000000000000000000 then IFFT image2 without padding and it wil

20、l looked like as below.3. MATLAB source code of my programfunction varargout = HW2(varargin)% HW2 M-file for HW2.fig% HW2, by itself, creates a new HW2 or raises the existing% singleton*.% H = HW2 returns the handle to a new HW2 or the handle to% the existing singleton*.% HW2(CALLBACK,hObject,eventD

21、ata,handles,.) calls the local% function named CALLBACK in HW2.M with the given input arguments.% HW2(Property,Value,.) creates a new HW2 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before HW2_OpeningFunction gets called. An% unrecognized

22、property name or invalid value makes property application% stop. All inputs are passed to HW2_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Copyright 2002-2003 The MathWorks, Inc.% Edit

23、 the above text to modify the response to help HW2% Last Modified by GUIDE v2.5 13-Nov-2006 00:53:05% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, HW2_OpeningFcn, . gui_OutputFcn, HW2_OutputFcn, . g

24、ui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before HW2 is made visi

25、ble.function HW2_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line argument

26、s to HW2 (see VARARGIN)% Choose default command line output for HW2handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes HW2 wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function v

27、arargout = HW2_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line ou

28、tput from handles structurevarargout1 = handles.output;function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) re

29、turns contents of edit1 as text% str2double(get(hObject,String) returns contents of edit1 as a double% - Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a fu

30、ture version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);end

31、function edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edit2 as text% str2double(get(hObject

32、,String) returns contents of edit2 as a double% - Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not cre

33、ated until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);end% - Executes on button press in pushbutton1.function pu

34、shbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%*PB1-1-start*%Lina imageimage1= get(handles.edit1,string);A=imread(image1);SZA=size(

35、A);% get the image size matrixSZAX=SZA(1);% get image x points amountSZAY=SZA(2);% get image y points amountADFT=double(zeros(SZAX,SZAY);ADFT1=double(zeros(SZAX,SZAY,SZAX,SZAY);%DFT imagefor u=1:SZAXfor v=1:SZAYfor x=1:SZAXfor y=1:SZAYADFT1(u,v,x,y)=double(A(x,y)*(-1)(x+y)*exp(-j*2*pi*(u-1)*(x-1)/SZ

36、AX+(v-1)*(y-1)/SZAY);endendADFT(u,v)=double(abs(sum(sum(ADFT1(u,v,:,:)/(SZAX*SZAY);endend%IDFT imageAIDFT=double(zeros(SZAX,SZAY);AIDFT1=double(zeros(SZAX,SZAY,SZAX,SZAY);for u=1:SZAXfor v=1:SZAYfor x=1:SZAXfor y=1:SZAYAIDFT1(u,v,x,y)=double(A(x,y)*exp(j*2*pi*(u-1)*(x-1)/SZAX+(v-1)*(y-1)/SZAY)/(-1)(

37、x+y);endendAIDFT(u,v)=double(abs(sum(sum(AIDFT1(u,v,:,:);endendfigure(name,origional image1); imshow (A)%Show original imagefigure(name,DFT image1); imshow (ADFT*20,min(ADFT(:) max(ADFT(:)%Show FFT imagefigure(name,IDFT image1); imshow (AIDFT*20,min(AIDFT(:) max(AIDFT(:)%Show IFFT image%My own image

38、image2= get(handles.edit2,string);A=imread(image2);SZA=size(A);% get the image size matrixSZAX=SZA(1);% get image x points amountSZAY=SZA(2);% get image y points amountADFT=double(zeros(SZAX,SZAY);ADFT1=double(zeros(SZAX,SZAY,SZAX,SZAY);%DFT imagefor u=1:SZAXfor v=1:SZAYfor x=1:SZAXfor y=1:SZAYADFT1

39、(u,v,x,y)=double(A(x,y)*(-1)(x+y)*exp(-j*2*pi*(u-1)*(x-1)/SZAX+(v-1)*(y-1)/SZAY);endendADFT(u,v)=double(abs(sum(sum(ADFT1(u,v,:,:)/(SZAX*SZAY);endend%IDFT imageAIDFT=double(zeros(SZAX,SZAY);AIDFT1=double(zeros(SZAX,SZAY,SZAX,SZAY);for u=1:SZAXfor v=1:SZAYfor x=1:SZAXfor y=1:SZAYAIDFT1(u,v,x,y)=doubl

40、e(A(x,y)*exp(j*2*pi*(u-1)*(x-1)/SZAX+(v-1)*(y-1)/SZAY)/(-1)(x+y);endendAIDFT(u,v)=double(abs(sum(sum(AIDFT1(u,v,:,:);endendfigure(name,origional image2); imshow (A)%Show original imagefigure(name,DFT image2); imshow (ADFT*20,min(ADFT(:) max(ADFT(:)%Show FFT imagefigure(name,IDFT image2); imshow (AID

41、FT*20,min(AIDFT(:) max(AIDFT(:)%Show IFFT image% - Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user d

42、ata (see GUIDATA)%*PB1-2-start*%set (handles.edit1,String,c:fig2.22(a).jpg);image1= get(handles.edit1,string);A=imread(image1);SZA=size(A);% get the image size matrixSZAX=SZA(1);% get image x points amountSZAY=SZA(2);% get image y points amount%FFT imageAA=fft2(double(A);AAA=double(abs(AA);AFFT=doub

43、le(fftshift(AAA);%IFFT imageIAA=ifft2(double(A);IAAA=double(abs(IAA);AIFFT=double(ifftshift(IAAA);%Show resultfigure(name,origional image1); imshow (A)%Show original image1figure(name,FFT image1); imshow (AFFT*40,min(AFFT(:) max(AFFT(:)%Show FFT image1figure(name,IFFT image1); imshow (AIFFT*25,min(A

44、IFFT(:) max(AIFFT(:)%Show IFFT image1%set (handles.edit2,String,c:myson.jpg);image2= get(handles.edit2,string);A=imread(image2);SZA=size(A);% get the image size matrixSZAX=SZA(1);% get image x points amountSZAY=SZA(2);% get image y points amount%FFT imageAA=fft2(double(A);AAA=double(abs(AA);AFFT=dou

45、ble(fftshift(AAA);%IFFT imageIAA=ifft2(double(A);IAAA=double(abs(IAA);AIFFT=double(ifftshift(IAAA);%Show resultfigure(name,origional image2); imshow (A)%Show original image1figure(name,FFT image2); imshow (AFFT*40,min(AFFT(:) max(AFFT(:)%Show FFT image1figure(name,IFFT image2); imshow (AIFFT*25,min(

46、AIFFT(:) max(AIFFT(:)%Show IFFT image1function edit3_Callback(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of

47、 edit3 as text% str2double(get(hObject,String) returns contents of edit3 as a double% - Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of M

48、ATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction edit4_Ca

49、llback(hObject, eventdata, handles)% hObject handle to edit4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edit4 as text% str2double(get(hObject,String) returns

50、contents of edit4 as a double% - Executes during object creation, after setting all properties.function edit4_CreateFcn(hObject, eventdata, handles)% hObject handle to edit4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after

51、all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);end% - Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%*PB2-1-start*im

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論