function varargout = tuxiangchuli(varargin)
%TUXIANGCHULI M-file for tuxiangchuli.fig
% TUXIANGCHULI, by itself, creates a new TUXIANGCHULI or raises the existing
% singleton*.
%
% H = TUXIANGCHULI returns the handle to a new TUXIANGCHULI or the handle to
% the existing singleton*.
%
% TUXIANGCHULI('Property','Value',...) creates a new TUXIANGCHULI using the
% given property value pairs. Unrecognized properties are passed via
% varargin to tuxiangchuli_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% TUXIANGCHULI('CALLBACK') and TUXIANGCHULI('CALLBACK',hObject,...) call the
% local function named CALLBACK in TUXIANGCHULI.M with the given input
% arguments.
%
% *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 tuxiangchuli
% Last Modified by GUIDE v2.5 30-Aug-2009 20:18:06
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @tuxiangchuli_OpeningFcn, ...
'gui_OutputFcn', @tuxiangchuli_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 tuxiangchuli is made visible.
function tuxiangchuli_OpeningFcn(hObject, eventdata, handles, varargin)
global img flag ImagenUmbral;
% 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 unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for tuxiangchuli
handles.output = hObject;
% Update handles structure
img=0;flag=0;ImagenUmbral=0;
set(handles.mysave,'enable','off');
guidata(hObject, handles);
% UIWAIT makes tuxiangchuli wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = tuxiangchuli_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;
% --------------------------------------------------------------------
function myfile_Callback(hObject, eventdata, handles)
% hObject handle to myfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function myview_Callback(hObject, eventdata, handles)
% hObject handle to myview (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function myedit_Callback(hObject, eventdata, handles)
% hObject handle to myedit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function myyawp_Callback(hObject, eventdata, handles)
% hObject handle to myyawp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function myfilter1_Callback(hObject, eventdata, handles)
% hObject handle to myfilter1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global img ImagenUmbral
img=ImagenUmbral;
if ~isequal(img, 0)
subplot(2,2,1);
imshow(img);
img=double(img);
[m n x]=size(img);
h3= fspecial('gaussian',[3,3], 0.5);
for k=1:x
img3(:,:,k)=conv2(img(:,:,1),h3,'same');
end
img3=uint8(img3);
subplot(2,2,2);
imshow(img3);
title('3*3模板');
h5= fspecial('gaussian',[5,5], 0.5);
for k=1:x
img5(:,:,k)=conv2(img(:,:,1),h5,'same');
end
img5=uint8(img5);
subplot(2,2,3);
imshow(img5);
title('5*5模板');
h7= fspecial('gaussian',[5,5], 0.5);
for k=1:x
img7(:,:,k)=conv2(img(:,:,1),h7,'same');
end
img7=uint8(img7);
subplot(2,2,4);
imshow(img7);
title('7*7模板');
question={'选用哪一个模板'};
response=questdlg(question,'提问对话框','3*3','5*5','7*7',2);
if response=='3*3'
ImagenUmbral=img3;
end
if response=='5*5'
ImagenUmbral=img5;
end
if response=='7*7'
ImagenUmbral=img7;
end
subplot(1,1,1);
imshow(ImagenUmbral);
end
% --------------------------------------------------------------------
function myfilter2_Callback(hObject, eventdata, handles)
% hObject handle to myfilter2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function mydisth_Callback(hObject, eventdata, handles)
% hObject handle to mydisth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%提高分辨率的思想是在图像的m 行之间的每两行之间加入一行,共m-1行,在图像的n列之间m 行之间的每两列之间加入一列,共n-1列,
%图像最终变为(2m-1)*(2n-1)大小。加入的像素若是在边沿则取上下或左右像素的平均值,否则加入像素取四个对角像素的平均值。
global img ImagenUmbral
img=ImagenUmbral;
if ~isequal(img, 0)
[m,n,x]=size(img);
ImagenUmbral=double(zeros(2*m-1,2*n-1,x));
for k=1:1:x
ImagenUmbral(1:2:end,1:2:end,k)=img(1:end,1:end,k);
for i=1:2:2*m-1
for j=2:2:2*n-2
ImagenUmbral(i,j,k)=(ImagenUmbral(i,j-1,k)+ImagenUmbral(i,j+1,k))/2;
end
end
for j=1:2:2*n-1
for i=2:2:2*m-2
ImagenUmbral(i,j,k)=(ImagenUmbral(i-1,j,k)+ImagenUmbral(i+1,j,k))/2;
end
end
for i=2:2:2*m-2
for j=2:2:2*n-2
ImagenUmbral(i,j,k)=(ImagenUmbral(i-1,j-1,k)+ImagenUmbral(i-1,j+1,k)+ImagenUmbral(i+1,j-1,k)+ImagenUmbral(i+1,j+1,k))/4;
end
end
end
subplot(1,1,1)
ImagenUmbral=uint8(round(ImagenUmbral));
imshow(ImagenUmbral);
end
% --------------------------------------------------------------------
function myequalhisto_Callback(hObject, eventdata, handles)
% hObject handle to myequalhisto (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global img ImagenUmbral
img=ImagenUmbral;
if ~isequal(img, 0)
I=rgb2gray(img);
J=histeq(I);
subplot(2,2,1);
imshow(I),title('原灰度图像');
subplot(2,2,2);
imshow(J),title('处理后的图像');
subplot(2,2,3);
imhist(I,64);
subplot(2,2,4);
imhist(J,64);
ImagenUmbral=J;
end
% --------------------------------------------------------------------
function myRGB_Callback(hObject, eventdata, handles)
% hObject handle to myRGB (see GCBO)
%