直方圖均衡含GUI_第1頁
直方圖均衡含GUI_第2頁
直方圖均衡含GUI_第3頁
直方圖均衡含GUI_第4頁
直方圖均衡含GUI_第5頁
已閱讀5頁,還剩1頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、Digital Image ProcessingHistogram Equalization with GUI module Author:Andonghui_20090802310067The histogram equalization code:%對一幅圖像進行直方圖均衡化A=rgb2gray(picture); %圖像的預處理,讀入彩色圖像將其灰度化m,n=size(A);B=zeros(size(A);l=m*n;r=zeros(1,256);y=zeros(1,256);A=double(A);for i=1:m for j=1:n r(A(i,j)+1)=r(A(i,j)+1)+

2、1; endendr=r./l;%得到原圖像各灰度級所占的比例for k=1:256 for j=1:k y(k)=y(k)+r(j); endend %直方圖累加 for k=1:256 y(k)=floor(255*y(k)+0.5); %確定映射關系endfor i=1:m for j=1:n B(i,j)=y(A(i,j)+1); endendA=uint8(A);%轉換為無符號整數(shù)B=uint8(B);imshow(B);%顯示均衡化后的圖像 The GUI Function interface:Function :Transform the image into gray and

3、add Gaussian noiseFunctin:show the histogram of the original gray imageFunction: show the result of using histogram equalizationFunction:show the histogram of the processed imageThe whole code(GUI):function varargout = c(varargin)% Copyright 2012 Andonghui% C M-file for c.fig% C, by itself, creates

4、a new C or raises the existing% singleton*.% H = C returns the handle to a new C or the handle to% the existing singleton*.% C('CALLBACK',hObject,eventData,handles,.) calls the local% function named CALLBACK in C.M with the given input arguments.% C('Property','Value',.) crea

5、tes a new C or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before c_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to c_OpeningFcn via varargin.% *See GUI O

6、ptions on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help c % Last Modified by GUIDE v2.5 29-Mar-2012 12:10:00% Begin initialization code - DO NOT EDITgui_Singleton

7、 = 1;gui_State = struct('gui_Name', mfilename, . 'gui_Singleton', gui_Singleton, . 'gui_OpeningFcn', c_OpeningFcn, . 'gui_OutputFcn', c_OutputFcn, . 'gui_LayoutFcn', , . 'gui_Callback', );if nargin && ischar(varargin1) gui_State.gui_Callback =

8、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 c is made visible.function c_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no outp

9、ut 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 arguments to c (see VARARGIN)% Choose default command line output for chandles.output = hObject;% Upd

10、ate handles structureguidata(hObject, handles);% UIWAIT makes c wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = c_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output arg

11、s (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 output from handles structurevarargout1 = handles.output;% - Executes on button press in read.function

12、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)guidata(hObject, handles);clear handles.picture;filename,pathname=uigetfile('D:

13、圖片1/*.*','select image');picture=pathname,filename;axes(handles.axes3);picture=imread(picture);imshow(picture)handles.picture=picture;guidata(hObject, handles);% - Executes on button press in gray.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (

14、see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)guidata(hObject, handles);picture=handles.picture; B=rgb2gray(picture);axes(handles.axes4)imshow(B);% - Executes on button press in magnify.function pushbutton5_Call

15、back(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)guidata(hObject, handles);picture=handles.picture;G = imnoise(picture,'gaussian',0,0.05); a

16、xes(handles.axes2);imshow(G);% - Executes on button press in reduce.function pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)guidat

17、a(hObject, handles);picture=handles.picture; average_filter_5x5 = fspecial('average', 5 5);filter_5x5 = imfilter (picture, average_filter_5x5);axes(handles.axes2);imshow(filter_5x5);% - Executes on button press in zhifangtu.function pushbutton7_Callback(hObject, eventdata, handles)% hObject

18、handle to pushbutton7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)guidata(hObject, handles);picture=handles.picture;C=rgb2gray(picture);r,c=size(C);axes(handles.axes2)imhist(C);% - Executes on button press in

19、 enhance.function pushbutton12_Callback(hObject, eventdata, handles)% hObject handle to pushbutton12 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)guidata(hObject, handles);picture=handles.picture;J=imadjust(pi

20、cture,0.4 0.6,0 1,1);axes(handles.axes2)imshow(J)% - Executes on button press in pushbutton14.function pushbutton14_Callback(hObject, eventdata, handles)% hObject handle to pushbutton14 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and u

21、ser data (see GUIDATA)close% - Executes on button press in pushbutton15.function pushbutton15_Callback(hObject, eventdata, handles)% hObject handle to pushbutton15 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)guidata(hObject, handles);picture=handles.picture; O=rgb2gray(picture);E=histeq(O);axes(handles.axes2);imhist(E);% - Executes on button

溫馨提示

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

評論

0/150

提交評論