




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Homework Assignment#2數位影像處理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
12、use 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 i
13、mage.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 “Len
14、a image” 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 mention
15、ed that 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
16、contrast 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 resu
17、lt, 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 wr
18、aparound 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
19、 after 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
20、 will 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',
21、hObject,eventData,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_OpeningFunct
22、ion gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to HW2_OpeningFcn via varargin.% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".% See also: GUIDE, GUIDATA, GUIHAN
23、DLES% Copyright 2002-2003 The MathWorks, Inc.% Edit 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
24、, . 'gui_OpeningFcn', HW2_OpeningFcn, . 'gui_OutputFcn', HW2_OutputFcn, . 'gui_LayoutFcn', , . 'gui_Callback', );if nargin && ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);el
25、se gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before HW2 is made visible.function HW2_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined i
26、n a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to HW2 (see VARARGIN)% Choose default command line output for HW2handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes HW2 wait for user res
27、ponse (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = HW2_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be define
28、d in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined
29、in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit1 as text% str2double(get(hObject,'String') returns contents of edit1 as a double% - Executes during object creation, after setting all prop
30、erties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%
31、See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor');endfunction edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be def
32、ined 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,'String') returns contents of edit2 as a double% - Executes during object creation, after setting all
33、 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 created until after all CreateFcns called% Hint: edit controls usually have a white background on Windo
34、ws.% 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 pushbutton1_Callback(hObject, eventdata, handles)% hObject han
35、dle 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(A);% get the image size matrixSZAX=SZA(1);% get im
36、age 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)/SZAX+(v-1)*(y-1)/SZAY);endendADFT(u,v)=double(abs(su
37、m(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)(x+y);endendAIDFT(u,v)=double(abs(sum(sum(AIDFT1(u,
38、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
39、 own imageimage2= 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:S
40、ZAXfor y=1:SZAYADFT1(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:SZAYA
41、IDFT1(u,v,x,y)=double(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
42、(ADFT(:)%Show FFT imagefigure('name','IDFT image2'); imshow (AIDFT*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
43、defined in a future version of MATLAB% handles structure with handles and user data (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
44、x points amountSZAY=SZA(2);% get image y points amount%FFT imageAA=fft2(double(A);AAA=double(abs(AA);AFFT=double(fftshift(AAA);%IFFT imageIAA=ifft2(double(A);IAAA=double(abs(IAA);AIFFT=double(ifftshift(IAAA);%Show resultfigure('name','origional image1'); imshow (A)%Show original imag
45、e1figure('name','FFT image1'); imshow (AFFT*40,min(AFFT(:) max(AFFT(:)%Show FFT image1figure('name','IFFT image1'); imshow (AIFFT*25,min(AIFFT(:) max(AIFFT(:)%Show IFFT image1%set (handles.edit2,'String','c:myson.jpg');image2= get(handles.edit2,'st
46、ring');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=double(fftshift(AAA);%IFFT imageIAA=ifft2(double(A);IAAA=double(abs(IAA);AIFFT=double(ifftshift(IAAA);%
47、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(AIFFT(:) max(AIFFT(:)%Show IFFT image1fu
48、nction 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 edit3 as text% str2double(get
49、(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 MATLAB% handles empty
50、 - 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');
51、endfunction edit4_Callback(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% str2doubl
52、e(get(hObject,'String') returns 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
53、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
54、39;);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*image1= get(handles.edit3,'string');A=double(imread(image1);SZA=size(A);% get the image size matrixSZAX=SZA(1);% get image x points amountSZAY=SZA(2);% get image y points amountLAPLACIAN=double(zeros(SZAX,SZAY);for x=1:SZAX for
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 热力系统自动化控制实施导
- 建立全员安全生产责任制的公司文件
- 自建房排查培训
- 文化传媒商标转让居间协议
- 教育改革与发展政策
- 酒吧改造拆除工程协议
- 农家乐创业全攻略
- 苏教版圆环的面积
- 铝矿运输产业联盟合作协议
- 电气设计工作年终总结
- 2025年中国建筑股份有限公司招聘笔试参考题库含答案解析
- 持续葡萄糖监测临床应用专家共识2024解读
- DB33T 2157-2018 公共机构绿色数据中心建设与运行规范
- 健康促进机关创建培训
- Unit3TheworldofScience大单元教学设计-高中英语
- 中国心力衰竭患者高钾血症管理专家共识2024解读
- DB51T 990-2020 小型泵站设计规程
- 护患沟通技巧课件
- 个人无偿劳务合同模板
- 钣金车间安全培训课件
- 混凝土工安全教育培训试题及答案
评论
0/150
提交评论