function varargout = Image_processing_GUI(varargin)
% IMAGE_PROCESSING_GUI MATLAB code for Image_processing_GUI.fig
% IMAGE_PROCESSING_GUI, by itself, creates a new IMAGE_PROCESSING_GUI or raises the existing
% singleton*.
%
% H = IMAGE_PROCESSING_GUI returns the handle to a new IMAGE_PROCESSING_GUI or the handle to
% the existing singleton*.
%
% IMAGE_PROCESSING_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in IMAGE_PROCESSING_GUI.M with the given input arguments.
%
% IMAGE_PROCESSING_GUI('Property','Value',...) creates a new IMAGE_PROCESSING_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Image_processing_GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Image_processing_GUI_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 Image_processing_GUI
% Last Modified by GUIDE v2.5 04-Sep-2021 08:30:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Image_processing_GUI_OpeningFcn, ...
'gui_OutputFcn', @Image_processing_GUI_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 Image_processing_GUI is made visible.
function Image_processing_GUI_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 Image_processing_GUI (see VARARGIN)
% Choose default command line output for Image_processing_GUI
handles.output = hObject;
set(handles.save,'Enable','off');
set(handles.exit,'Enable','off');
set(handles.reset,'Enable','off');
set(handles.g1,'Visible','off');
set(handles.g2,'Visible','off');
set(handles.g3,'Visible','off');
set(handles.g4,'Visible','off');
set(handles.g5,'Visible','off');
set(handles.n1,'Enable','off');
set(handles.n2,'Enable','off');
set(handles.n3,'Enable','off');
set(handles.n4,'Enable','off');
set(handles.f1,'Enable','off');
set(handles.f2,'Enable','off');
set(handles.f3,'Enable','off');
set(handles.slider1,'Enable','off');
set(handles.slider2,'Enable','off');
set(handles.slider3,'Enable','off');
set(handles.slider4,'Enable','off');
set(handles.slider5,'Enable','off');
set(handles.m1,'Enable','off');
set(handles.m2,'Enable','off');
set(handles.m3,'Enable','off');
set(handles.m4,'Enable','off');
set(handles.m5,'Enable','off');
set(handles.m6,'Enable','off');
set(handles.m7,'Enable','off');
set(handles.m8,'Enable','off');
set(handles.m9,'Enable','off');
set(handles.p1,'Enable','off');
set(handles.p2,'Enable','off');
set(handles.p3,'Enable','off');
set(handles.p4,'Enable','off');
set(handles.p5,'Enable','off');
set(handles.invc,'Enable','off');
set(handles.dia,'Enable','off');
set(handles.ero,'Enable','off');
set(handles.strel,'Enable','off');
set(handles.strels,'Enable','off');
set(handles.strelv,'Enable','off');
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Image_processing_GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Image_processing_GUI_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;
%示波器g4彩色图象更新函数
function updateg4(handles)
r=handles.img(:,:,1);
g=handles.img(:,:,2);
b=handles.img(:,:,3);
x=size(r);
x=(1:x(1,2));
r=r(1,:);
g=g(1,:);
b=b(1,:);
axes(handles.g4);
cla;
plot(x,r,'r');
hold on
plot(x,g,'g');
plot(x,b,'b');
hold off;
ImageData1 = reshape(handles.img(:,:,1), [size(handles.img, 1) * size(handles.img, 2) 1]);
ImageData2 = reshape(handles.img(:,:,2), [size(handles.img, 1) * size(handles.img, 2) 1]);
ImageData3 = reshape(handles.img(:,:,3), [size(handles.img, 1) * size(handles.img, 2) 1]);
[H1, X1] = hist(ImageData1, 1:5:256);
[H2, X2] = hist(ImageData2, 1:5:256);
[H3, X3] = hist(ImageData3, 1:5:256);
axes(handles.g5);
cla;
hold on;
plot(X1, H1, 'r');
plot(X2, H2, 'g');
plot(X3, H3, 'b');
axis([0 256 0 max([H1 H2 H3])]);
%示波器灰色图象更新函数
function updateg4_1(handles)
k=handles.img(:,:,1);
x=size(k);
x=(1:x(1,2));
k=k(1,:);
axes(handles.g4);
cla;
plot(x,k,'k');
ImageData = reshape(handles.img, [size(handles.img, 1) * size(handles.img, 2) 1]);
[H, X] = hist(ImageData, 1:5:256);
axes(handles.g5);
cla;
hold on;
plot(X, H, 'k');
axis([0 256 0 max(H)]);
%打开
% --- Executes on button press in load.
function load_Callback(hObject, eventdata, handles)
[file path]=uigetfile({'*.jpg';'*.bmp';'*.jpeg';'*.png'}, '打开文件');
image=[path file];
handles.file=image;
if (file==0)
warndlg('请选择一张图片...') ;
end
[fpath, fname, fext]=fileparts(file);
validex=({'.bmp','.jpg','.jpeg','.png'});
found=0;
for (x=1:length(validex))
if (strcmpi(fext,validex{x}))
found=1;
set(handles.save,'Enable','on');
set(handles.exit,'Enable','on');
set(handles.reset,'Enable','on');
set(handles.g1,'Visible','on');
set(handles.g2,'Visible','on');
set(handles.g3,'Visible','on');
set(handles.g4,'Visible','on');
set(handles.g5,'Visible','on');
set(handles.n1,'Enable','on');
set(handles.n2,'Enable','on');
set(handles.n3,'Enable','on');
set(handles.n4,'Enable','on');
set(handles.f1,'Enable','on');
set(handles.f2,'Enable','on');
set(handles.f3,'Enable','on');
set(handles.slider1,'Enable','on');
set(handles.slider2,'Enable','on');
set(handles.slider3,'Enable','on');
set(handles.slider4,'Enable','on');
set(handles.slider5,'Enable','on');
set(handles.m1,'Enable','on');
set(handles.m2,'Enable','on');
set(handles.m3,'Enable','on');
set(handles.m4,'Enable','on');
set(handles.m5,'Enable','on');
set(handles.m6,'Enable','on');
set(handles.m7,'Enable','on');
set(handles.m8,'Enable','on');
set(handles.m9,'Enable','on');
set(handles.p1,'Enable','on');
set(handles.p2,'Enable','on');
set(handles.p3,'Enable','on');
set(handles.p4,'Enable','on');
set(handles.p5,'Enable','on');
set(handles.invc,'Enable','on');
set(handles.dia,'Enable','on');
set(handles.ero,'Enable','on');
set(handles.strel,'Enable','on');
set(handles.strels,'Enable','on');
set(handles.strelv,'Enable','on');
handles.img=imread(image);
handles.i=imread(image);
h = waitbar(0,'等待...');
steps = 100;
for step = 1:steps
waitbar(step / steps)
end
close(h)
axes(handles.g1);
cla;
imshow(handles.img);
axes(handles.g2);
cla;
imshow(handles.img);
guidata(hObject,handles);
break;
end
end
if (found==0)
errordlg('文件扩展名不正确,请从可用扩展名[.jpg、.jpeg、.bmp、.png]中选择文件','Image Format Error');
end
set(handles.g3,'Visible','on');
set(handles.g4,'Visible','on');
% 示波器g3更新
mysize=size(handles.img);
if numel(mysize)>2
r=handles.i(:,:,1);
g=handles.i(:,:,2);
b=handles.i(:,:,3);
x=size(r);
x=(1:x(1,2));
r=r(1,:);
g=g(1,:);
b=b(1,:);