khunnior 2014-06-07 06:52
浏览 1491

MATLAB小波图像去噪运行错误

function varargout = wavlet(varargin)
% WAVLET M-file for wavlet.fig
% WAVLET, by itself, creates a new WAVLET or raises the existing
% singleton*.
%
% H = WAVLET returns the handle to a new WAVLET or the handle to
% the existing singleton*.
%
% WAVLET('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WAVLET.M with the given input arguments.
%
% WAVLET('Property','Value',...) creates a new WAVLET or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before wavlet_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to wavlet_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 wavlet

% Last Modified by GUIDE v2.5 21-Jun-2004 11:13:32

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @wavlet_OpeningFcn, ...
'gui_OutputFcn', @wavlet_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 wavlet is made visible.
function wavlet_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 wavlet (see VARARGIN)

% Choose default command line output for wavlet
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes wavlet wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = wavlet_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 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 future 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

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)
global pp;
pp=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes on button press in pushbutton1.
function pushbutton1_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)
global pp;
global psnr_noise_remove;
load psnr_noise_remove;
global psnr;
load psnr;
%读入原始图像并显示
i=imread('lena.bmp');
subplot(2,2,1);
imshow(i);
title('原始图像');
axis square;

%生成含噪图像并显示
j=imnoise(i,'gaussian',0,pp);
subplot(2,2,2);
imshow(j);
title('含噪图像');
axis square;
%用sym4小波函数对j进行2层分解
[c,l]=wavedec2(j,2,'sym4');
%实现低通滤波消噪
a1=uint8(wrcoef2('a',c,l,'sym4',2));
%用coif2小波函数对j进行2层分解
[gc,gl]=wavedec2(a1,2,'coif2');
n=[1,2];%设置尺度向量
p=[10.28,24.08];%设置阈值向量
%对三个高频系数进行阈值处理
nc=wthcoef2('h',gc,gl,n,p,'s');
nc=wthcoef2('v',gc,gl,n,p,'s');
nc=wthcoef2('d',gc,gl,n,p,'s');
mc=wthcoef2('h',gc,gl,n,p,'s');
mc=wthcoef2('v',gc,gl,n,p,'s');
mc=wthcoef2('d',gc,gl,n,p,'s');
%对更新后的小波分解结构进行阈值处理
x2=waverec2(mc,gl,'coif2');
%进行中值滤波
for ii=1:252;
for jj=1:252;
temp=0;
for m=0:3
for n=0:3
temp=temp+double(x2(ii+m,jj+n));
end
end
temp=temp/16;
x4(ii,jj)=temp;
end
end
for ii=253:256
for jj=253:256
x4(ii,jj)=double(i(ii,jj));
end
end
%显示去噪图像

subplot(2,2,3);
imshow(uint8(x4));
title('消噪图像');
axis square;
%计算psnr
q=0.0;
for x=1:256;
for j=1:256;
diff=x4(x,j)-double(i(x,j));

q=q+diff*diff;
end
end
psnr_y = q / (256*256);
psnr_y = (255 * 255)/psnr_y;
set(psnr_noise_remove,'String',psnr_y);
for ii=1:10
if psnr(ii)==0
psnr(ii)=psnr_y;
break;
end
end
save psnr psnr;
% --- 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 created until after all CreateFcns called
global psnr_noise_remove;
% 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

psnr_noise_remove=hObject;
save psnr_noise_remove psnr_noise_remove;

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,'String')) returns contents of edit2 as a double

运行之后一直红色提示
??? function varargout = wavlet(varargin)
|
Error: Function definitions are not permitted at the prompt or in scripts.
是什么情况,怎么改

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?