📄 datagh1.m
字号:
function varargout = datagh1(varargin)
% DATAGH1 M-file for datagh1.fig
% DATAGH1, by itself, creates a new DATAGH1 or raises the existing
% singleton*.
%
% H = DATAGH1 returns the handle to a new DATAGH1 or the handle to
% the existing singleton*.
%
% DATAGH1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DATAGH1.M with the given input arguments.
%
% DATAGH1('Property','Value',...) creates a new DATAGH1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before datagh1_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to datagh1_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 datagh1
% Last Modified by GUIDE v2.5 03-Jun-2005 08:28:01
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @datagh1_OpeningFcn, ...
'gui_OutputFcn', @datagh1_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 datagh1 is made visible.
function datagh1_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 datagh1 (see VARARGIN)
% Choose default command line output for datagh1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes datagh1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = datagh1_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 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 I1;
I1=imread('lily.tif');
%subplot(2,2,1);
imshow(I1);% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global I1;
global I2;
I2=rgb2gray(I1);
%subplot(2,2,2);
imshow(I2);% --- 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'));endfunction 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)% 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 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)global aa;
global I1;
x1=0;x2=0;y1=0;y2=0;
aa=get(handles.edit1,'String');
eval(aa);
J1=I1;
k=(y2-y1)/(x2-x1);
for x=x1:0.1:x2
y=k*(x-x1)+y1;
x=round(x);
y=round(y);
J1(y,x,1)=10;
J1(y,x,2)=10;
J1(y,x,3)=10;
end
imshow(J1);
% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global aa;
global I1;
x=0;
ax=0;ay=0;
aa=get(handles.edit1,'String');
eval(aa);
J=I1;
x1=size(I1,1);x2=size(I1,2);
pi=3.14;
th=(3.14/180)*x;
for x=1:x1
for y=1:x2
J(x,y,1)=0;
J(x,y,2)=0;
J(x,y,3)=0;
i=(x-ay)*cos(th)+(y-ax)*(-sin(th))+ax;
j=(x-ay)*sin(th)+(y-ax)*cos(th)+ay;
i=round(i);j=round(j);
if(i>0&j>0&i<=x1&j<=x2)
J(x,y,1)=I1(i,j,1);
J(x,y,2)=I1(i,j,2);
J(x,y,3)=I1(i,j,3);
end
end
end
imshow(J);% --- Executes on button press in pushbutton5.function pushbutton5_Callback(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)
global aa;
global I1;
x=0;y=0;r=0;l=0;r=0;
a=1;b=1;
aa=get(handles.edit1,'String');
eval(aa);
l1=size(I1,1);l2=size(I1,2);
if (r<10)
l=3;
elseif((r>=10)&(r<20))
l=10;
elseif((r>=20)&(r<30))
l=20;
elseif((r>=30)&(r<50))
l=40;
else
l=80;
end
J1=I1;for(i=1:l1)
for(j=1:l2)
r1=(j-x)*(j-x)/a+(i-y)*(i-y)/b;
s=r1-r*r;
if(s>=-l&&s<=l)
J1(i,j,1)=11;
J1(i,j,2)=11;
J1(i,j,3)=230;
end
end
end
imshow(J1);% --- Executes on button press in pushbutton6.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)
global I1;
global ar;
x=1;
ar=get(handles.edit1,'String');
eval(ar);I2=rgb2gray(I1);
l1=size(I2,1);l2=size(I2,2);
for i=2:l1-2
for j=2:l2-2
aa=double(i)+1;
bb=double(j)+1;
fx=abs(double(I2(aa,bb))-double(I2(i,j)));
fy=abs(double(I2(aa,j))-double(I2(i,bb)));
f=fx+fy;
if (f>x)
c(i,j)=200;
else
c(i,j)=0;
end
end
end
imshow(c)% --- Executes on button press in pushbutton25.function pushbutton25_Callback(hObject, eventdata, handles)% hObject handle to pushbutton25 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global I1;
ar=get(handles.edit1,'String');
eval(ar);
if (x>2)
x=2;
elseif (x<0.5)
x=0.5;
end
l1=size(I1,1);l2=size(I1,2);
for i=1:1:l1
for j=1:l2
x1=round(i*x);y1=round(j*x);
x2=x1+1;
y2=y1+1;
a1(x1,y1,1)=I1(i,j,1);
a1(x1,y1,2)=I1(i,j,2);
a1(x1,y1,3)=I1(i,j,3);
a1(x2,y1,1)=I1(i,j,1);
a1(x2,y1,2)=I1(i,j,2);
a1(x2,y1,3)=I1(i,j,3);
a1(x1,y2,1)=I1(i,j,1);
a1(x1,y2,2)=I1(i,j,2);
a1(x1,y2,3)=I1(i,j,3);
a1(x2,y2,1)=I1(i,j,1);
a1(x2,y2,2)=I1(i,j,2);
a1(x2,y2,3)=I1(i,j,3);
end
end
figure,
imshow(a1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -