matlab guiglobal,请问Gui中用global

function Untitled_5_Callback(hObject, eventdata, handles)

% hObject    handle to Untitled_5 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

global im;

[filename, pathname]=uigetfile({'*.jpg;*.tif;*.png;*.gif';'All Image Files'},'read the picture');

str=[pathname filename];

im=imread(str);

guidata(hObject,handles);

set(handles.edit1,'string',str);

axes(handles.axes1);

imshow(im);

% --------------------------------------------------------------------

function Untitled_6_Callback(hObject, eventdata, handles)

% hObject    handle to Untitled_6 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

clc;

clear all;

close(gcf);

% --------------------------------------------------------------------

function Untitled_7_Callback(hObject, eventdata, handles)

% hObject    handle to Untitled_7 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

global im;

global gray;

cla(handles.axes2,'reset');

axes(handles.axes2);

gray=rgb2gray(im);

imshow(gray);

% --------------------------------------------------------------------

function Untitled_8_Callback(hObject, eventdata, handles)

% hObject    handle to Untitled_8 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

global gray;

global I;

I=medfilt2(gray,[3 3]);

cla(handles.axes2,'reset');

axes(handles.axes2);

imshow(I);

% --------------------------------------------------------------------

function Untitled_9_Callback(hObject, eventdata, handles)

% hObject    handle to Untitled_9 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

global I;

global J;

[W,H]=size(I);

for x=2:W-1

for y=2:H-1

R1=(-1)*I(x-1,y-1)+I(x+1,y-1)-2*I(x-1,y)+2*I(x+1,y)-I(x-1,y+1)+I(x+1,y+1);  %%横向检测

R2=I(x-1,y-1)+2*I(x,y-1)+I(x+1,y-1)-I(x-1,y+1)-2*I(x,y+1)-I(x+1,y+1);       %%纵向检测

R3=I(x,y-1)+2*I(x+1,y-1)-I(x-1,y)+I(x+1,y)-2*I(x+1,y+1)-I(x,y+1);           %%45°算子检测

R4=2*I(x-1,y-1)+I(x,y-1)+I(x-1,y)-I(x+1,y)-I(x,y+1)-2*I(x+1,y+1);           %%-45°算子检测

R0=[abs(R1),abs(R2),abs(R3),abs(R4)];

R=sort(R0,'descend');

switch(R(1))

case abs(R1)

J(x,y)=R1;

case abs(R2)

J(x,y)=R2;

case abs(R3)

J(x,y)=R3;

case abs(R4)

J(x,y)=R4;

end

end

end

cla(handles.axes2,'reset');

axes(handles.axes2);

imshow(J);

figure,imhist(J);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值