[Image denoising] Image denoising based on matlab GUI median + mean + Wiener + wavelet filtering [including Matlab source code 753]

[Image denoising] Image denoising based on matlab GUI median + mean + Wiener + wavelet filtering [including Matlab source code 753]

1. Introduction

Image denoising based on matlab GUI median + mean + Wiener + wavelet filtering

2. the source code

function varargout = dsp1(varargin) % DSP1 MATLAB code for dsp1.fig % DSP1, by itself, creates a new DSP1 or raises the existing % singleton*. % % H = DSP1 returns the handle to a new DSP1 or the handle to % the existing singleton*. % % DSP1( 'CALLBACK' ,hObject,eventData,handles,...) calls the local % function named CALLBACK in DSP1.M with the given input arguments. % % DSP1( 'Property' , 'Value' ,...) creates a new DSP1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before dsp1_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to dsp1_OpeningFcn via varargin. % % *See GUI Options 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 dsp1 % Last Modified by GUIDE v2 .5 21 -Mar -2014 21 : 34 : 03 % Begin initialization code-DO NOT EDIT gui_Singleton = 1 ; gui_State = struct( 'gui_Name' , mfilename, ... 'gui_Singleton' , gui_Singleton, ... 'gui_OpeningFcn' , @dsp1_OpeningFcn, ... 'gui_OutputFcn' , @dsp1_OutputFcn, ... 'gui_LayoutFcn' , [] ,. .. 'gui_Callback' , []); if nargin && ischar (varargin{ 1 }) gui_State.gui_Callback = str2func(varargin{ 1 }); end if nargout [varargout{ 1 :nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code-DO NOT EDIT % --- Executes just before dsp1 is made visible. function dsp1_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 arguments to dsp1 (see VARARGIN) setappdata ( handles.figure1 , 'img1' , 0 ) ; setappdata(handles.figure1, 'img2' , 0 ); setappdata(handles.figure1, 'img3' , 0 ); % set (handles.myimage_compress, 'Enable' , 'off' ); set (handles.pushbutton_compress, 'Enable' , 'off' ); set (handles.menu_quzaodesc, 'Enable' , 'off' ); set (handles. save, 'Enable' , 'off' ); % Choose default command line output for dsp1 handles.output = hObject; % Update handles structure guidata (hObject, handles) ; % UIWAIT makes dsp1 wait for user response (see UIRESUME) % uiwait ( handles.figure1 ) ; % --- Outputs from this function are returned to the command line. function varargout = dsp1_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 output from handles structure varargout { 1 } = handles.output ; % --- Executes on selection change in popupmenu. function popupmenu_Callback (hObject, eventdata, handles) % hObject handle to popupmenu (see GCBO) % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject, 'String' )) returns popupmenu contents as cell array % contents{get(hObject, 'Value' )} returns selected item from popupmenu val = get(hObject, 'Value' ); str = get(hObject, 'String' ); switch str{val}; case'None ' % img2=getappdata(handles.figure1, 'img1' ); axes(handles.axes2); imshow(img2); setappdata(handles.figure1, 'img2' ,img2); set (handles.pushbutton_listen, 'Enable' , 'off' ); case'Gaussian noise' % img2=getappdata(handles.figure1, 'img1' ); img2 = imnoise(img2, 'gaussian' );% add Gaussian noise axes(handles.axes2); imshow(img2); setappdata(handles.figure1, 'img2' ,img2); set (handles.menu_quzaodesc, 'Enable' , 'on' ); set (handles.pushbutton_listen, 'Enable' , 'on' ); case'Salt and Pepper Noise' % img2=getappdata(handles.figure1, 'img1' ); img2 = imnoise(img2, 'salt' ); axes(handles.axes2); imshow(img2); setappdata (handles.figure1, 'IMG2' , IMG2); SET (handles.menu_quzaodesc, 'the Enable' , 'ON' ); SET (handles.pushbutton_listen, 'the Enable' , 'ON' ); Case 'Poisson noise' % img2=getappdata(handles.figure1, 'img1' ); img2 = imnoise(img2, 'poisson' ); axes(handles.axes2); imshow(img2); setappdata (handles.figure1, 'IMG2' , IMG2); SET (handles.menu_quzaodesc, 'the Enable' , 'ON' ); SET (handles.pushbutton_listen, 'the Enable' , 'ON' ); Case 'speckle noise speckle' % img2=getappdata(handles.figure1, 'img1' ); img2 = imnoise(img2, 'speckle' ); axes(handles.axes2); imshow(img2); setappdata(handles.figure1, 'img2' ,img2); set (handles.menu_quzaodesc, 'Enable' , 'on' ); set (handles.pushbutton_listen, 'Enable' , 'on' ); end % --- Executes during object creation, after setting all properties. function popupmenu_CreateFcn (hObject, eventdata, handles) % hObject handle to popupmenu (see GCBO) % eventdata reserved-to be defined in a future version of MATLAB % handles empty-handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal (get(hObject, 'BackgroundColor' ), get( 0 , 'defaultUicontrolBackgroundColor' )) set (hObject, 'BackgroundColor' , 'white' ) ; end % ------------------------------------------------- ------------------- function myfile_Callback (hObject, eventdata , handles) % hObject handle to myfile (see GCBO) % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % ------------------------------------------------- ------------------- function myfile_open_Callback (hObject, eventdata , handles) % hObject handle to myfile_open (see GCBO) % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [filename, pathname] = uigetfile(... { '*.bmp;*.jpg; *.png; *.jpeg; ' , 'Image Files(*.bmp,*.jpg,*.png,*.jpeg)' ;... '*.*' , 'All Files(*.*)' }... , 'Pick an image' );% open the file and select the image if isequal (filename, 0 ) || isequal (pathname, 0 ) return ;% if you click "Cancel" end axes (handles.axes1) ;% important, in which Axis display image fpath = [pathname filename];% path name and file name img1 = imread(fpath);% read image imshow(img1);% display image setappdata(handles.figure1, 'img1' ,img1); % --- Executes on selection change in popupmenu 3. function popupmenu3_Callback (hObject, eventdata, handles) % hObject handle to popupmenu3 (see GCBO) % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject, 'String' )) returns popupmenu3 contents as cell array % contents{get(hObject, 'Value' )} returns selected item from popupmenu3 img2=getappdata(handles.figure1, 'img2' );%Noise image img1=getappdata(handles.figure1, 'img1' );% original image val = get(hObject, 'Value' ); str = get(hObject, 'String' ); switch str(val); case'Median filtering' set (handles.uipanel_lowfilt, 'Visible' , 'off' ); set (handles.uipanel_gausslow, 'Visible' , 'off ' ); set (handles.pushbutton_quzao, 'Visible' , 'off' ); img3 = medfilt2(img2);% median filter setappdata(handles.figure1, 'img3' ,img3); axes(handles.axes3); imshow(img3); PSNR = psnr2(img3, img1); str1 = strcat ( 'psnr is: ' , num2str(PSNR), 'db' ); set (handles.text3, 'string' , str1);% display PSNR value set (handles.save, 'Enable' , 'on' ); % SET (handles.myimage_compress, 'the Enable' , 'ON' ); SET (handles.pushbutton_compress, 'the Enable' , 'ON' ); Case 'Wiener filter' SET (handles.uipanel_lowfilt, 'the Visible' , 'OFF' ); set (handles.uipanel_gausslow, 'Visible' , 'off' ); set (handles.pushbutton_quzao, 'Visible' , 'off' ); img3 = wiener2(img2,[ 5 , 5 ]); setappdata(handles.figure1, 'img3' ,img3); axes(handles.axes3); imshow(img3); PSNR = psnr2(img3, img1); str1 = strcat ( 'psnr is: ' , num2str(PSNR), 'db' ); set (handles.text3, 'string' , str1); % set (handles.myimage_compress, 'Enable' , 'on' ); set (handles.pushbutton_compress, 'Enable' , 'on' ); set (handles.save, 'Enable' , 'on' ); case ' ' set (handles.uipanel_lowfilt, 'Visible' , 'off' ); set (handles.uipanel_gausslow, 'Visible' , 'off' ); set (handles.pushbutton_quzao, 'Visible' , 'off'); [c,s]=wavedec2(img2, 2 , 'sym4' );% Use wavelet function sym4 to perform two-layer wavelet decomposition on img3 %a1=wrcoef2( 'a' ,c,s, 'sym4' , 1 );% extract the low-frequency image of the first layer in the wavelet decomposition, which realizes the low-pass filter denoising %subplot( 2 , 2 , 3 );imshow(uint8(a1));% draw the image after the first denoising img3=wrcoef2( 'a' ,c,s, 'sym4' , 2 );% extract the low-frequency image of the second layer in the wavelet decomposition, which realizes low-pass filtering and denoising setappdata(handles.figure1, 'img3' ,uint8(img3)); axes(handles.axes3); imshow(uint8(img3));% draw the image after the second denoising PSNR = psnr2(img3, img1); str1 = strcat ( 'psnr is: ' , num2str(PSNR), 'db' ); set (handles.text3, 'string' , str1); % set (handles.myimage_compress, 'Enable' , 'on' ); set (handles.pushbutton_compress, 'Enable' , 'on' ); set (handles.save, 'Enable' , 'on' ); case'ideal low Pass filter' set (handles.uipanel_gausslow, 'Visible' , 'off' ); set (handles.uipanel_lowfilt, 'Visible' , 'on' ); set (handles.pushbutton_quzao, 'Visible' , 'on') case'Gaussian low-pass filter' set (handles.uipanel_lowfilt, 'Visible' , 'off' ); set (handles.uipanel_gausslow, 'Visible' , 'on' ); set (handles.pushbutton_quzao, 'Visible' , 'on' ); end guidata (hObject,handles) % --- Executes during object creation, after setting all properties. function popupmenu3_CreateFcn (hObject, eventdata, handles) % hObject handle to popupmenu3 (see GCBO) % eventdata reserved-to be defined in a future version of MATLAB % handles empty-handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal (get(hObject, 'BackgroundColor' ), get( 0 , 'defaultUicontrolBackgroundColor' )) set (hObject, 'BackgroundColor' , 'white' ) ; end Copy code

3. running results

4. remarks

Version: 2014a
requires complete code or writing plus QQ 1564658423