📄 zaosheng.m
字号:
function varargout = zaosheng(varargin)
% ZAOSHENG M-file for zaosheng.fig
% ZAOSHENG, by itself, creates a new ZAOSHENG or raises the existing
% singleton*.
%
% H = ZAOSHENG returns the handle to a new ZAOSHENG or the handle to
% the existing singleton*.
%
% ZAOSHENG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ZAOSHENG.M with the given input arguments.
%
% ZAOSHENG('Property','Value',...) creates a new ZAOSHENG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before zaosheng_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to zaosheng_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help zaosheng
% Last Modified by GUIDE v2.5 04-Dec-2007 13:58:05
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @zaosheng_OpeningFcn, ...
'gui_OutputFcn', @zaosheng_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 zaosheng is made visible.
function zaosheng_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 zaosheng (see VARARGIN)
% Choose default command line output for zaosheng
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes zaosheng wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = zaosheng_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 open1.
function open1_Callback(hObject, eventdata, handles)
% hObject handle to open1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file,path]=uigetfile('*.jpg;*.tif');
if isequal(file,0)
disp('User selected Cancel')
else
filename=fullfile(path,file);
end
picture=imread(filename);
[r,c,d]=size(picture);
axes(handles.yuantu1)
set(handles.yuantu1, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[0 r],'yLim',[0 c]);
imshow(picture);
hold on
%确定所选区域的范围
figure(2);
imshow(picture);
[c1,r1,P] = impixel(picture)
r2=abs(r1(4)-r1(1))
c2=abs(c1(2)-c1(1))
a=zeros(r2,c2);
for i=1:r2
for j=1:c2
a(i,j)=picture(i+r1(1),j+abs(c1(1)));
end
end
a=uint8(a);
%显示截取后图像
axes(handles.jiequtu1)
set(handles.jiequtu1, 'Visible', 'off', 'Units', 'pixels','XLim',[0 r2],'yLim',[0 c2]);
image(a);
hold on
%显示直方图
axes(handles.zhifangtu1)
set(handles.zhifangtu1, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[1 256]);
[count,x]=imhist(a);
y=count/(r2*c2);
stem(x,y,'.');
hold off
% --- Executes on button press in open2.
function open2_Callback(hObject, eventdata, handles)
% hObject handle to open2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file,path]=uigetfile('*.jpg;*.tif');
if isequal(file,0)
disp('User selected Cancel')
else
filename=fullfile(path,file);
end
picture=imread(filename);
[r,c,d]=size(picture);
axes(handles.yuantu2)
set(handles.yuantu2, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[0 r],'yLim',[0 c]);
imshow(picture);
hold on
%确定所选区域的范围
figure(3)
imshow(picture);
[c1,r1,P] = impixel(picture);
r2=abs(r1(4)-r1(1));
c2=abs(c1(2)-c1(1));
a=zeros(r2,c2);
for i=1:abs(r1(4)-r1(1))
for j=1:abs(c1(2)-c1(1))
a(i,j)=picture(i+r1(1),j+c1(1));
end
end
a=uint8(a);
%显示截取后图像
axes(handles.jiequtu2)
set(handles.jiequtu2, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[0 r2],'yLim',[0 c2]);
image(a);
hold on
%显示直方图
[count,x]=imhist(a);
axes(handles.zhifangtu2)
set(handles.zhifangtu2, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[0 255]);
y=count/(r2*c2);
stem(x,y,'.');
hold off
% --- Executes on button press in gaosilvbo.
function gaosilvbo_Callback(hObject, eventdata, handles)
% hObject handle to gaosilvbo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
zaosheng2();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -