基于matlab的GUI图像处理
2013-05-07 14:38
267 查看
先上图吧:
这个是界面效果图:(一律下拉菜单)
图像滤波效果图:
代码:
以下这是.m文件(fig文件在资源里,可以免费下载弱弱的加一句,其实资源里也有这个.m文件,呵呵)
function varargout = tuxiangchuli(varargin)
% GUIDETEMPLATE0 M-file for guidetemplate0.fig
% GUIDETEMPLATE0, by itself, creates a new GUIDETEMPLATE0 or raises the existing
% singleton*.
%
% H = GUIDETEMPLATE0 returns the handle to a new GUIDETEMPLATE0 or the handle to
% the existing singleton*.
%
% GUIDETEMPLATE0('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUIDETEMPLATE0.M with the given input arguments.
%
% GUIDETEMPLATE0('Property','Value',...) creates a new GUIDETEMPLATE0 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before guidetemplate0_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to guidetemplate0_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 guidetemplate0
% Last Modified by GUIDE v2.5 08-Jan-2013 14:12:19
% 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 guidetemplate0 is made visible.
function tuxiangchuli_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 guidetemplate0 (see VARARGIN)
% Choose default command line output for guidetemplate0
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes guidetemplate0 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;
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
% --- Executes during object creation, after setting all properties.
function axes2_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes2
% --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject handle to file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function openfile_Callback(hObject, eventdata, handles)
% hObject handle to openfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
[name,path]=uigetfile('*.*','');
file=[path,name];
axes(handles.axes1);
x=imread(file);
handles.img=x;
guidata(hObject, handles);
imshow(x);
% --------------------------------------------------------------------
function savefile_Callback(hObject, eventdata, handles)
% hObject handle to savefile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
[filename,pathname]=uiputfile({'*.jpg';'*.bmp';'*.tif';'*.*'},'save image as');
file=strcat(pathname,filename);
i=getimage(gca);
imwrite(i,file);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function exit_Callback(hObject, eventdata, handles)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc;
close all;
close('gcf');
% --- Executes on button press in ReloadRecentImage.
function ReloadRecentImage_Callback(hObject, eventdata, handles)
% hObject handle to ReloadRecentImage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% x=(handles.img);
% [row,col,Cnums]=size(x);
% axes(handles.axes2);
% imshow(zeros([256,256]));
% if Cnums==1
% if (row<=256)&(col<=256)
% W=256;
% else
% W=max(row,col);
% end
% for m=1:W
% for n=1:W
% if (m<=row)&(n<=col)
% extendx(m,n)=x(m,n);
% else
% extendx(m,n)=realmax;
% end
% end
% end
% axes(handles.axes1);
% Imshow(extendx);
% else
% if (row<=256)&(col<=256)
% W=256;
% else
% W=max(row,col);
% end
% for m=1:W
% for n=1:W
% if (m<=row)&(n<=col)
% extendx(m,n,:)=x(m,n,:);
% else
% extendx(m,n,:)=realmax;
% end
% end
% end
%
% % Imshow(extendx);
%
% msgbox('Please transform it to a monochrome image or it can not be processed correctly','fileopening','warning');
% end
% axes(handles.axes1);
% Imshow(extendx);
% guidata(hObject, handles);
global x;
set(handles.axes2,'HandleVisibility','on');
axes(handles.axes2);
y=getimage(gca);
axes(handles.axes1);
imshow(y);
set(handles.axes2,'HandleVisibility','off');
% --------------------------------------------------------------------
function edit_Callback(hObject, eventdata, handles)
% hObject handle to edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function liangdu_Callback(hObject, eventdata, handles)
% hObject handle to liangdu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert1','insert2','insert gamma'};
defans={'[0 0.7]','[0 1]','1'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
p2=str2num(p{2});
p3=str2num(p{3});
gamma=p3;
global x;
y=imadjust(x,p1,p2,gamma);
imshow(y);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function style_Callback(hObject, eventdata, handles)
% hObject handle to style (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function suoyinse_Callback(hObject, eventdata, handles)
% hObject handle to suoyinse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=grayslice(x,64);
imshow(y);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function erzhitu_Callback(hObject, eventdata, handles)
% hObject handle to erzhitu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=im2bw(x,0.4);
imshow(y);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function huidu_Callback(hObject, eventdata, handles)
% hObject handle to huidu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
if isrgb(x)
im=rgb2gray(x);
imshow(im);
handles.img=im;
else
msgbox('it is a gray picture','failure');
end
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function jietu_Callback(hObject, eventdata, handles)
% hObject handle to jietu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
y=imcrop(handles.img);
imshow(y);
axes(handles.axes2);
imwrite(y,'jietu.jpg');
handles.Timage=y;
set(handles.axes2,'HandleVisibility','OFF');
% --- Executes on slider movement.
function liangdutiaojietiao_Callback(hObject, eventdata, handles)
% hObject handle to liangdutiaojietiao (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','on');
x=(handles.img);
n=get(handles.liangdutiaojietiao,'value');
v=get(handles.gamma,'value');
y=imadjust(x,[0 n],[0 1],v);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --- Executes during object creation, after setting all properties.
function liangdutiaojietiao_CreateFcn(hObject, eventdata, handles)
% hObject handle to liangdutiaojietiao (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function gamma_Callback(hObject, eventdata, handles)
% hObject handle to gamma (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','on');
x=(handles.img);
v=get(handles.gamma,'value');
n=get(handles.liangdutiaojietiao,'value');
y=imadjust(x,[0 n],[0 1],v);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --- Executes during object creation, after setting all properties.
function gamma_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --------------------------------------------------------------------
function tool_Callback(hObject, eventdata, handles)
% hObject handle to tool (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function big_Callback(hObject, eventdata, handles)
% hObject handle to big (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert the multiple:'};
defans={'5'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
y=imresize(x,p1,'nearest');
figure,imshow(handles.img);
figure,imshow(y);
imwrite(y,'fangda.jpg');
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function small_Callback(hObject, eventdata, handles)
% hObject handle to small (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert the multiple:'};
defans={'0.5'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
y=imresize(x,p1,'nearest');
figure,imshow(x);
figure,imshow(y);
imwrite(y,'suoxiao.jpg');
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function turn_Callback(hObject, eventdata, handles)
% hObject handle to turn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function lturn_Callback(hObject, eventdata, handles)
% hObject handle to lturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imrotate(x,-90);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function rturn_Callback(hObject, eventdata, handles)
% hObject handle to rturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imrotate(x,-90);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function udturn_Callback(hObject, eventdata, handles)
% hObject handle to udturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
if isrgb(handles.img)
for k=1:3
y(:,:,k)=flipud(x(:,:,k));
end
imshow(y);
else
x=(handles.img);
y=flipud(x);
imshow(y);
end
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function lrturn_Callback(hObject, eventdata, handles)
% hObject handle to lrturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
if isrgb(handles.img)
for k=1:3
y(:,:,k)=fliplr(x(:,:,k));
end
imshow(y);
else
x=(handles.img);
y=fliplr(x);
imshow(y);
end
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function allturn_Callback(hObject, eventdata, handles)
% hObject handle to allturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
prompt={'insert1:'};
defans={'45'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
y=imrotate(handles.img,p1);
imshow(y);
set(handles.axes2,'HandleVisibility','off');
% --------------------------------------------------------------------
function txyunsuan_Callback(hObject, eventdata, handles)
% hObject handle to txyunsuan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in multiply.
function multiply_Callback(hObject, eventdata, handles)
% hObject handle to multiply (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
prompt={'insert1:'};
defans={'8'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
j=immultiply(x,p1);
imshow(j);
set(handles.axes2,'HandleVisibility','off');
% --- Executes on button press in divide.
function divide_Callback(hObject, eventdata, handles)
% hObject handle to divide (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
prompt={'insert1:'};
defans={'3'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
j=imdivide(x,p1);
imshow(j);
set(handles.axes2,'HandleVisibility','off');
% --------------------------------------------------------------------
function txdiejia_Callback(hObject, eventdata, handles)
% hObject handle to txdiejia (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
i=(handles.img);
n=imresize(i,[256 256]);
j=imread('116.bmp');
v=imresize(j,[256 256]);
k=imadd(n,v);
imshow(k);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function sub_Callback(hObject, eventdata, handles)
% hObject handle to sub (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% x=(handles.img);
% set(handles.axes2,'HandleVisibility','ON');
% axes(handles.axes2);
% se=strel('disk',15);
% b=imopen(x,se);
% y=imsubtract(y,b);
% imshow(y);
% set(handles.axes2,'HandleVisibility','off');
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
i=(handles.img);
n=imresize(i,[256 256]);
j=imread('116.bmp');
v=imresize(j,[256 256]);
k=imsubtract(n,v);
imshow(k);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function fangshe_Callback(hObject, eventdata, handles)
% hObject handle to transform (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
tform = maketform('affine',[0.5 0 0; .5 1 0; 0 0 1]);
J = imtransform(x,tform);
imshow(J);
set(handles.axes2,'HandleVisibility','off');
% --------------------------------------------------------------------
function pinyu_Callback(hObject, eventdata, handles)
% hObject handle to pinyu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function flour_Callback(hObject, eventdata, handles)
% hObject handle to fft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
m=fft2(x(:,:,1));
y=fftshift(m);
imshow(log(abs(y)),[]);
else
m=fft2(x);
y=fftshift(m);
imshow(log(abs(y)),[]);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function cos_Callback(hObject, eventdata, handles)
% hObject handle to cos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
m=rgb2gray(x);
y=dct2(m);
imshow(log(abs(y)),[]);
else
y=dct2(x);
imshow(log(abs(y)),[]);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function radon_Callback(hObject, eventdata, handles)
% hObject handle to radon (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
theta=0:180;
if isrgb(x)
m=rgb2gray(x);
[r,xp]=radon(m,theta);
imagesc(theta,xp,r);
else
[r,xp]=radon(x,theta);
imagesc(theta,xp,r);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function zaos_Callback(hObject, eventdata, handles)
% hObject handle to zaos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function gaos_Callback(hObject, eventdata, handles)
% hObject handle to gaos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert1:','insert2'};
defans={'0','0.02'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
p2=str2num(p{2});
y=imnoise(handles.img,'gaussian',p1,p2);
imshow(y);
handles.noise_img=y;
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function jiaoy_Callback(hObject, eventdata, handles)
% hObject handle to jiaoy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
prompt={'insert1:'};
defans={'0.05'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
y=imnoise(x,'salt & pepper',p1);
imshow(y);
handles.noise_img=y;
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function bandian_Callback(hObject, eventdata, handles)
% hObject handle to bandian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert1:'};
defans={'0.04'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
y=imnoise(handles.img,'speckle');
imshow(y);
handles.noise_img=y;
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function poisson_Callback(hObject, eventdata, handles)
% hObject handle to poisson (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imnoise(handles.img,'poisson');
imshow(y);
handles.noise_img=y;
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function lvboqi_Callback(hObject, eventdata, handles)
% hObject handle to lvboqi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Butterworth_Callback(hObject, eventdata, handles)
% hObject handle to Butterworth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
%if isrgb(x)
% msgbox('it is not a gray picture','failure');
%else
%y1=imnoise(x,'salt & pepper');
f=double(x);
g=fft2(f);
g=fftshift(g);
[M,N,O]=size(g);
nn=2;
d0=8;
m=fix(M/2); n=fix(N/2);o=fix(O/2);
for i=1:M
for j=1:N
for z=1:O
d=sqrt((i-m)^2+(j-n)^2+(z-o)^2);
h=1/(1+0.414*(d/d0)^(2*nn));
result(i,j,z)=h*g(i,j,z);
end
end
end
result=ifftshift(result);
y2=ifft2(result);
y3=uint8(real(y2));
%figure,imshow(y1);
imshow(y3);
%end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function explvbo_Callback(hObject, eventdata, handles)
% hObject handle to explvbo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y1=imnoise(x,'gaussian',0.01);
[M,N]=size(y1);
F=fft2(y1);
fftshift(F);
Dcut=100;
D0=250;
D1=150;
for u=1:M
for v=1:N
D(u,v)=sqrt(u^2+v^2);
EXPOTH(u,v)=exp(log(1/sqrt(2))*(Dcut/D(u,v))^2);
end
end
figure,imshow(y1);
EXPOTG=EXPOTH.*F;
EXPOTfiltered=ifft2(EXPOTG);
imshow(EXPOTfiltered);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function tixinglvbo_Callback(hObject, eventdata, handles)
% hObject handle to tixinglvbo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imnoise(x,'gaussian',0.01);
[M,N]=size(y);
F=fft2(y);
fftshift(F);
Dcut=100;
D0=250;
D1=150;
for u=1:M
for v=1:N
D(u,v)=sqrt(u^2+v^2);
if D(u,v)<D1
THPFH(u,v)=0;
elseif D(u,v)<=D0
D(u,v)=(D(u,v)-D1/(D0-D1));
else
THPFH(u,v)=1;
end
end
end
figure,imshow(y)
THPFG=THPFH.*F;
THPFfiltered=ifft2(THPFG);
imshow(THPFfiltered);
set(handles.axes2,'HandleVisibility','OFF')
% --------------------------------------------------------------------
function auto_Callback(hObject, eventdata, handles)
% hObject handle to auto (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
y=imnoise(x,'gaussian',0,0.005);
z=wiener2(y,[5 5]);
figure,imshow(y);
imshow(z);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function tuxiangfx_Callback(hObject, eventdata, handles)
% hObject handle to tuxiangfx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function bianyuanjianc_Callback(hObject, eventdata, handles)
% hObject handle to bianyuanjianc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function sobel_Callback(hObject, eventdata, handles)
% hObject handle to sobel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'sobel');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function roberts_Callback(hObject, eventdata, handles)
% hObject handle to roberts (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'roberts');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function canny_Callback(hObject, eventdata, handles)
% hObject handle to canny (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'canny');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function Laplacian_Callback(hObject, eventdata, handles)
% hObject handle to Laplacian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'log');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function prewitt_Callback(hObject, eventdata, handles)
% hObject handle to prewitt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'prewitt');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function zhifangtu_Callback(hObject, eventdata, handles)
% hObject handle to zhifangtu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function rzft_Callback(hObject, eventdata, handles)
% hObject handle to rzft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
x=imhist(handles.img(:,:,1));
x1=x(1:10:256);
horz=1:10:256;
bar(horz,x1);
set(handles.axes2,'xtick',0:50:255);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function gzft_Callback(hObject, eventdata, handles)
% hObject handle to gzft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
x=imhist(handles.img(:,:,2));
x1=x(1:10:256);
horz=1:10:256;
bar(horz,x1);
set(handles.axes2,'xtick',0:50:255);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function bzft_Callback(hObject, eventdata, handles)
% hObject handle to bzft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
x=imhist(handles.img(:,:,3));
x1=x(1:10:256);
horz=1:10:256;
bar(horz,x1);
set(handles.axes2,'xtick',0:50:255);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function txzengqiang_Callback(hObject, eventdata, handles)
% hObject handle to txzengqiang (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function zftjunheng_Callback(hObject, eventdata, handles)
% hObject handle to zftjunheng (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
if isrgb(x)
a=histeq(x(:,:,1));
b=histeq(x(:,:,2));
c=histeq(x(:,:,3));
k(:,:,1)=a;
k(:,:,2)=b;
k(:,:,3)=c;
imshow(k);
else
h=histeq(x);
imshow(h);
end
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function zsyjh_Callback(hObject, eventdata, handles)
% hObject handle to zsyjh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
if isrgb(x)
a=adapthistep(x(:,:,1));
b=adapthistep(x(:,:,2));
c=adapthistep(x(:,:,3));
k(:,:,1)=a;
k(:,:,2)=b;
k(:,:,3)=c;
imshow(k);
else
h=adapthisteq(x);
imshow(h);
end
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function smooth_Callback(hObject, eventdata, handles)
% hObject handle to smooth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function lingyu_Callback(hObject, eventdata, handles)
% hObject handle to lingyu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
h=ones(5,5)/25;
y=imfilter(x,h);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function wiener_Callback(hObject, eventdata, handles)
% hObject handle to wiener (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=wiener2(x,[5 5]);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function unsmooth_Callback(hObject, eventdata, handles)
% hObject handle to unsmooth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function zhongzhilvbo_Callback(hObject, eventdata, handles)
% hObject handle to zhongzhilvbo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
y=imnoise(x,'salt & pepper',0.04);
z=medfilt2(y,[5 5],'symmetric');
imshow(z);
imwrite(z,'medfilt.jpg');
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function ruihua_Callback(hObject, eventdata, handles)
% hObject handle to ruihua (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function laplacian_Callback(hObject, eventdata, handles)
% hObject handle to laplacian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
n=double(x);
v=fspecial('laplacian');
y=filter2(v,n);
k=n-y;
imshow(k);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function las_Callback(hObject, eventdata, handles)
% hObject handle to las (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
n=double(x);
H=[0 1 0,1 -4 1,0 1 0];
v=conv2(n,H,'same');
y=n-v;
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function fxianxruihua_Callback(hObject, eventdata, handles)
% hObject handle to fxianxruihua (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function tidumo_Callback(hObject, eventdata, handles)
% hObject handle to tidumo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
n=fspecial('sobel');
y=filter2(n,x);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function xiaobo_Callback(hObject, eventdata, handles)
% hObject handle to xiaobo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[c,l]=wavedec2(x,1,'sym4');
Csize=size(c);
for i=1:Csize(2)
if(c(i)>100)
c(i)=2*c(i);
else
c(i)=0.5*c(i);
end
end
x=waverec2(c,l,'sym4');
imshow(x);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function xianxing_Callback(hObject, eventdata, handles)
% hObject handle to xianxing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imadjust(x,[0 1],[1 0],1.5);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function feixianxing_Callback(hObject, eventdata, handles)
% hObject handle to feixianxing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=double(x);
n=0.05*log(y+1);
imshow(n);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function hdbianhuan_Callback(hObject, eventdata, handles)
% hObject handle to hdbianhuan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function ellip_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
%椭圆低通滤波器
Wp=0.26;Ws=0.51;Rp=3;Rs=8;
[N1,Wn1] = ellipord(Wp,Ws,Rp,Rs);
[num,den]=ellip(N1,Rp,Rs,Wn1);
dhL(1:M,1:N,o)=AL(1:M,1:N);
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to ellip (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function cheby2_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Wp=0.25;Ws=0.72;Rp=4;Rs=10;
[N1,Wn1] = cheb2ord(Wp,Ws,Rp,Rs);
[num,den]=cheby2(N1,Rp,Wn1)
dhL(1:M,1:N,o)=AL(1:M,1:N);
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to cheby2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function cheby1_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
%切比雪夫1型低通滤波器
Wp =0.27;Ws =0.52;Rp =4;Rs =9;
[N2,Wn2] = cheb1ord(Wp,Ws,Rp,Rs);
[num,den] =cheby1(N2,Rp,Wn2,'low');
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to cheby1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
%切比雪夫1型低通滤波器
Wp =0.27;Ws =0.52;Rp =4;Rs =9;
[N2,Wn2] = cheb1ord(Wp,Ws,Rp,Rs);
[num,den] =cheby1(N2,Rp,Wn2,'low');
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function firlvboqi_Callback(hObject, eventdata, handles)
% hObject handle to firlvboqi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function blackman_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1300;Fs=7500;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+18;
taper=blackman(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to blackman (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function hamming_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1300;Fs=6900;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+8;
taper=hamming(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to hamming (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function hanning_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1600;Fs=7200;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+5;
taper=hanning(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to hanning (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function cheby_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1600;Fs=7200;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+24;
taper=chebwin(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to cheby (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function kaiser_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=2000;Fs=6800;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+3;
taper=kaiser(N+1,beta);
num=fir1(N,Wn,ftype,taper);
den=1;
for k=1:N
x=AL(:,k);
AL(:,k)=filter(num,den,x);%设计出的IIR滤波器的参数num,den
end
dhL(1:M,1:N,o)=AL(1:M,1:N);
%按行处理
for i=1:M
y=AI(i,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
dhI(1:M,1:N,o)=AI(1:M,1:N);
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to kaiser (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function battlet_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1600;Fs=7200;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+138;
taper=bartlett(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to cheby1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
这个是界面效果图:(一律下拉菜单)
图像滤波效果图:
代码:
以下这是.m文件(fig文件在资源里,可以免费下载弱弱的加一句,其实资源里也有这个.m文件,呵呵)
function varargout = tuxiangchuli(varargin)
% GUIDETEMPLATE0 M-file for guidetemplate0.fig
% GUIDETEMPLATE0, by itself, creates a new GUIDETEMPLATE0 or raises the existing
% singleton*.
%
% H = GUIDETEMPLATE0 returns the handle to a new GUIDETEMPLATE0 or the handle to
% the existing singleton*.
%
% GUIDETEMPLATE0('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUIDETEMPLATE0.M with the given input arguments.
%
% GUIDETEMPLATE0('Property','Value',...) creates a new GUIDETEMPLATE0 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before guidetemplate0_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to guidetemplate0_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 guidetemplate0
% Last Modified by GUIDE v2.5 08-Jan-2013 14:12:19
% 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 guidetemplate0 is made visible.
function tuxiangchuli_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 guidetemplate0 (see VARARGIN)
% Choose default command line output for guidetemplate0
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes guidetemplate0 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;
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
% --- Executes during object creation, after setting all properties.
function axes2_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes2
% --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject handle to file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function openfile_Callback(hObject, eventdata, handles)
% hObject handle to openfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
[name,path]=uigetfile('*.*','');
file=[path,name];
axes(handles.axes1);
x=imread(file);
handles.img=x;
guidata(hObject, handles);
imshow(x);
% --------------------------------------------------------------------
function savefile_Callback(hObject, eventdata, handles)
% hObject handle to savefile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
[filename,pathname]=uiputfile({'*.jpg';'*.bmp';'*.tif';'*.*'},'save image as');
file=strcat(pathname,filename);
i=getimage(gca);
imwrite(i,file);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function exit_Callback(hObject, eventdata, handles)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc;
close all;
close('gcf');
% --- Executes on button press in ReloadRecentImage.
function ReloadRecentImage_Callback(hObject, eventdata, handles)
% hObject handle to ReloadRecentImage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% x=(handles.img);
% [row,col,Cnums]=size(x);
% axes(handles.axes2);
% imshow(zeros([256,256]));
% if Cnums==1
% if (row<=256)&(col<=256)
% W=256;
% else
% W=max(row,col);
% end
% for m=1:W
% for n=1:W
% if (m<=row)&(n<=col)
% extendx(m,n)=x(m,n);
% else
% extendx(m,n)=realmax;
% end
% end
% end
% axes(handles.axes1);
% Imshow(extendx);
% else
% if (row<=256)&(col<=256)
% W=256;
% else
% W=max(row,col);
% end
% for m=1:W
% for n=1:W
% if (m<=row)&(n<=col)
% extendx(m,n,:)=x(m,n,:);
% else
% extendx(m,n,:)=realmax;
% end
% end
% end
%
% % Imshow(extendx);
%
% msgbox('Please transform it to a monochrome image or it can not be processed correctly','fileopening','warning');
% end
% axes(handles.axes1);
% Imshow(extendx);
% guidata(hObject, handles);
global x;
set(handles.axes2,'HandleVisibility','on');
axes(handles.axes2);
y=getimage(gca);
axes(handles.axes1);
imshow(y);
set(handles.axes2,'HandleVisibility','off');
% --------------------------------------------------------------------
function edit_Callback(hObject, eventdata, handles)
% hObject handle to edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function liangdu_Callback(hObject, eventdata, handles)
% hObject handle to liangdu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert1','insert2','insert gamma'};
defans={'[0 0.7]','[0 1]','1'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
p2=str2num(p{2});
p3=str2num(p{3});
gamma=p3;
global x;
y=imadjust(x,p1,p2,gamma);
imshow(y);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function style_Callback(hObject, eventdata, handles)
% hObject handle to style (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function suoyinse_Callback(hObject, eventdata, handles)
% hObject handle to suoyinse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=grayslice(x,64);
imshow(y);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function erzhitu_Callback(hObject, eventdata, handles)
% hObject handle to erzhitu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=im2bw(x,0.4);
imshow(y);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function huidu_Callback(hObject, eventdata, handles)
% hObject handle to huidu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
if isrgb(x)
im=rgb2gray(x);
imshow(im);
handles.img=im;
else
msgbox('it is a gray picture','failure');
end
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function jietu_Callback(hObject, eventdata, handles)
% hObject handle to jietu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
y=imcrop(handles.img);
imshow(y);
axes(handles.axes2);
imwrite(y,'jietu.jpg');
handles.Timage=y;
set(handles.axes2,'HandleVisibility','OFF');
% --- Executes on slider movement.
function liangdutiaojietiao_Callback(hObject, eventdata, handles)
% hObject handle to liangdutiaojietiao (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','on');
x=(handles.img);
n=get(handles.liangdutiaojietiao,'value');
v=get(handles.gamma,'value');
y=imadjust(x,[0 n],[0 1],v);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --- Executes during object creation, after setting all properties.
function liangdutiaojietiao_CreateFcn(hObject, eventdata, handles)
% hObject handle to liangdutiaojietiao (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function gamma_Callback(hObject, eventdata, handles)
% hObject handle to gamma (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','on');
x=(handles.img);
v=get(handles.gamma,'value');
n=get(handles.liangdutiaojietiao,'value');
y=imadjust(x,[0 n],[0 1],v);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --- Executes during object creation, after setting all properties.
function gamma_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --------------------------------------------------------------------
function tool_Callback(hObject, eventdata, handles)
% hObject handle to tool (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function big_Callback(hObject, eventdata, handles)
% hObject handle to big (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert the multiple:'};
defans={'5'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
y=imresize(x,p1,'nearest');
figure,imshow(handles.img);
figure,imshow(y);
imwrite(y,'fangda.jpg');
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function small_Callback(hObject, eventdata, handles)
% hObject handle to small (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert the multiple:'};
defans={'0.5'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
y=imresize(x,p1,'nearest');
figure,imshow(x);
figure,imshow(y);
imwrite(y,'suoxiao.jpg');
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function turn_Callback(hObject, eventdata, handles)
% hObject handle to turn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function lturn_Callback(hObject, eventdata, handles)
% hObject handle to lturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imrotate(x,-90);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function rturn_Callback(hObject, eventdata, handles)
% hObject handle to rturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imrotate(x,-90);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function udturn_Callback(hObject, eventdata, handles)
% hObject handle to udturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
if isrgb(handles.img)
for k=1:3
y(:,:,k)=flipud(x(:,:,k));
end
imshow(y);
else
x=(handles.img);
y=flipud(x);
imshow(y);
end
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function lrturn_Callback(hObject, eventdata, handles)
% hObject handle to lrturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
if isrgb(handles.img)
for k=1:3
y(:,:,k)=fliplr(x(:,:,k));
end
imshow(y);
else
x=(handles.img);
y=fliplr(x);
imshow(y);
end
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function allturn_Callback(hObject, eventdata, handles)
% hObject handle to allturn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
prompt={'insert1:'};
defans={'45'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
y=imrotate(handles.img,p1);
imshow(y);
set(handles.axes2,'HandleVisibility','off');
% --------------------------------------------------------------------
function txyunsuan_Callback(hObject, eventdata, handles)
% hObject handle to txyunsuan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in multiply.
function multiply_Callback(hObject, eventdata, handles)
% hObject handle to multiply (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
prompt={'insert1:'};
defans={'8'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
j=immultiply(x,p1);
imshow(j);
set(handles.axes2,'HandleVisibility','off');
% --- Executes on button press in divide.
function divide_Callback(hObject, eventdata, handles)
% hObject handle to divide (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
prompt={'insert1:'};
defans={'3'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
j=imdivide(x,p1);
imshow(j);
set(handles.axes2,'HandleVisibility','off');
% --------------------------------------------------------------------
function txdiejia_Callback(hObject, eventdata, handles)
% hObject handle to txdiejia (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
i=(handles.img);
n=imresize(i,[256 256]);
j=imread('116.bmp');
v=imresize(j,[256 256]);
k=imadd(n,v);
imshow(k);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function sub_Callback(hObject, eventdata, handles)
% hObject handle to sub (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% x=(handles.img);
% set(handles.axes2,'HandleVisibility','ON');
% axes(handles.axes2);
% se=strel('disk',15);
% b=imopen(x,se);
% y=imsubtract(y,b);
% imshow(y);
% set(handles.axes2,'HandleVisibility','off');
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
i=(handles.img);
n=imresize(i,[256 256]);
j=imread('116.bmp');
v=imresize(j,[256 256]);
k=imsubtract(n,v);
imshow(k);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function fangshe_Callback(hObject, eventdata, handles)
% hObject handle to transform (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
tform = maketform('affine',[0.5 0 0; .5 1 0; 0 0 1]);
J = imtransform(x,tform);
imshow(J);
set(handles.axes2,'HandleVisibility','off');
% --------------------------------------------------------------------
function pinyu_Callback(hObject, eventdata, handles)
% hObject handle to pinyu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function flour_Callback(hObject, eventdata, handles)
% hObject handle to fft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
m=fft2(x(:,:,1));
y=fftshift(m);
imshow(log(abs(y)),[]);
else
m=fft2(x);
y=fftshift(m);
imshow(log(abs(y)),[]);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function cos_Callback(hObject, eventdata, handles)
% hObject handle to cos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
m=rgb2gray(x);
y=dct2(m);
imshow(log(abs(y)),[]);
else
y=dct2(x);
imshow(log(abs(y)),[]);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function radon_Callback(hObject, eventdata, handles)
% hObject handle to radon (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
theta=0:180;
if isrgb(x)
m=rgb2gray(x);
[r,xp]=radon(m,theta);
imagesc(theta,xp,r);
else
[r,xp]=radon(x,theta);
imagesc(theta,xp,r);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function zaos_Callback(hObject, eventdata, handles)
% hObject handle to zaos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function gaos_Callback(hObject, eventdata, handles)
% hObject handle to gaos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert1:','insert2'};
defans={'0','0.02'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
p2=str2num(p{2});
y=imnoise(handles.img,'gaussian',p1,p2);
imshow(y);
handles.noise_img=y;
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function jiaoy_Callback(hObject, eventdata, handles)
% hObject handle to jiaoy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
prompt={'insert1:'};
defans={'0.05'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
y=imnoise(x,'salt & pepper',p1);
imshow(y);
handles.noise_img=y;
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function bandian_Callback(hObject, eventdata, handles)
% hObject handle to bandian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
prompt={'insert1:'};
defans={'0.04'};
p=inputdlg(prompt,'insert',1,defans);
p1=str2num(p{1});
y=imnoise(handles.img,'speckle');
imshow(y);
handles.noise_img=y;
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function poisson_Callback(hObject, eventdata, handles)
% hObject handle to poisson (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imnoise(handles.img,'poisson');
imshow(y);
handles.noise_img=y;
guidata(hObject,handles);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function lvboqi_Callback(hObject, eventdata, handles)
% hObject handle to lvboqi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Butterworth_Callback(hObject, eventdata, handles)
% hObject handle to Butterworth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
%if isrgb(x)
% msgbox('it is not a gray picture','failure');
%else
%y1=imnoise(x,'salt & pepper');
f=double(x);
g=fft2(f);
g=fftshift(g);
[M,N,O]=size(g);
nn=2;
d0=8;
m=fix(M/2); n=fix(N/2);o=fix(O/2);
for i=1:M
for j=1:N
for z=1:O
d=sqrt((i-m)^2+(j-n)^2+(z-o)^2);
h=1/(1+0.414*(d/d0)^(2*nn));
result(i,j,z)=h*g(i,j,z);
end
end
end
result=ifftshift(result);
y2=ifft2(result);
y3=uint8(real(y2));
%figure,imshow(y1);
imshow(y3);
%end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function explvbo_Callback(hObject, eventdata, handles)
% hObject handle to explvbo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y1=imnoise(x,'gaussian',0.01);
[M,N]=size(y1);
F=fft2(y1);
fftshift(F);
Dcut=100;
D0=250;
D1=150;
for u=1:M
for v=1:N
D(u,v)=sqrt(u^2+v^2);
EXPOTH(u,v)=exp(log(1/sqrt(2))*(Dcut/D(u,v))^2);
end
end
figure,imshow(y1);
EXPOTG=EXPOTH.*F;
EXPOTfiltered=ifft2(EXPOTG);
imshow(EXPOTfiltered);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function tixinglvbo_Callback(hObject, eventdata, handles)
% hObject handle to tixinglvbo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imnoise(x,'gaussian',0.01);
[M,N]=size(y);
F=fft2(y);
fftshift(F);
Dcut=100;
D0=250;
D1=150;
for u=1:M
for v=1:N
D(u,v)=sqrt(u^2+v^2);
if D(u,v)<D1
THPFH(u,v)=0;
elseif D(u,v)<=D0
D(u,v)=(D(u,v)-D1/(D0-D1));
else
THPFH(u,v)=1;
end
end
end
figure,imshow(y)
THPFG=THPFH.*F;
THPFfiltered=ifft2(THPFG);
imshow(THPFfiltered);
set(handles.axes2,'HandleVisibility','OFF')
% --------------------------------------------------------------------
function auto_Callback(hObject, eventdata, handles)
% hObject handle to auto (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
y=imnoise(x,'gaussian',0,0.005);
z=wiener2(y,[5 5]);
figure,imshow(y);
imshow(z);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function tuxiangfx_Callback(hObject, eventdata, handles)
% hObject handle to tuxiangfx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function bianyuanjianc_Callback(hObject, eventdata, handles)
% hObject handle to bianyuanjianc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function sobel_Callback(hObject, eventdata, handles)
% hObject handle to sobel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'sobel');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function roberts_Callback(hObject, eventdata, handles)
% hObject handle to roberts (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'roberts');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function canny_Callback(hObject, eventdata, handles)
% hObject handle to canny (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'canny');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function Laplacian_Callback(hObject, eventdata, handles)
% hObject handle to Laplacian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'log');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function prewitt_Callback(hObject, eventdata, handles)
% hObject handle to prewitt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
if isrgb(x)
msgbox('it is not a gray picture','failure');
else
y=edge(x,'prewitt');
imshow(y);
end
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function zhifangtu_Callback(hObject, eventdata, handles)
% hObject handle to zhifangtu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function rzft_Callback(hObject, eventdata, handles)
% hObject handle to rzft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
x=imhist(handles.img(:,:,1));
x1=x(1:10:256);
horz=1:10:256;
bar(horz,x1);
set(handles.axes2,'xtick',0:50:255);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function gzft_Callback(hObject, eventdata, handles)
% hObject handle to gzft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
x=imhist(handles.img(:,:,2));
x1=x(1:10:256);
horz=1:10:256;
bar(horz,x1);
set(handles.axes2,'xtick',0:50:255);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function bzft_Callback(hObject, eventdata, handles)
% hObject handle to bzft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
x=imhist(handles.img(:,:,3));
x1=x(1:10:256);
horz=1:10:256;
bar(horz,x1);
set(handles.axes2,'xtick',0:50:255);
set(handles.axes2,'HandleVisibility','Off');
% --------------------------------------------------------------------
function txzengqiang_Callback(hObject, eventdata, handles)
% hObject handle to txzengqiang (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function zftjunheng_Callback(hObject, eventdata, handles)
% hObject handle to zftjunheng (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
if isrgb(x)
a=histeq(x(:,:,1));
b=histeq(x(:,:,2));
c=histeq(x(:,:,3));
k(:,:,1)=a;
k(:,:,2)=b;
k(:,:,3)=c;
imshow(k);
else
h=histeq(x);
imshow(h);
end
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function zsyjh_Callback(hObject, eventdata, handles)
% hObject handle to zsyjh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
if isrgb(x)
a=adapthistep(x(:,:,1));
b=adapthistep(x(:,:,2));
c=adapthistep(x(:,:,3));
k(:,:,1)=a;
k(:,:,2)=b;
k(:,:,3)=c;
imshow(k);
else
h=adapthisteq(x);
imshow(h);
end
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function smooth_Callback(hObject, eventdata, handles)
% hObject handle to smooth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function lingyu_Callback(hObject, eventdata, handles)
% hObject handle to lingyu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
h=ones(5,5)/25;
y=imfilter(x,h);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function wiener_Callback(hObject, eventdata, handles)
% hObject handle to wiener (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=wiener2(x,[5 5]);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function unsmooth_Callback(hObject, eventdata, handles)
% hObject handle to unsmooth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function zhongzhilvbo_Callback(hObject, eventdata, handles)
% hObject handle to zhongzhilvbo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
x=(handles.img);
y=imnoise(x,'salt & pepper',0.04);
z=medfilt2(y,[5 5],'symmetric');
imshow(z);
imwrite(z,'medfilt.jpg');
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function ruihua_Callback(hObject, eventdata, handles)
% hObject handle to ruihua (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function laplacian_Callback(hObject, eventdata, handles)
% hObject handle to laplacian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
n=double(x);
v=fspecial('laplacian');
y=filter2(v,n);
k=n-y;
imshow(k);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function las_Callback(hObject, eventdata, handles)
% hObject handle to las (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
n=double(x);
H=[0 1 0,1 -4 1,0 1 0];
v=conv2(n,H,'same');
y=n-v;
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function fxianxruihua_Callback(hObject, eventdata, handles)
% hObject handle to fxianxruihua (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function tidumo_Callback(hObject, eventdata, handles)
% hObject handle to tidumo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
n=fspecial('sobel');
y=filter2(n,x);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function xiaobo_Callback(hObject, eventdata, handles)
% hObject handle to xiaobo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[c,l]=wavedec2(x,1,'sym4');
Csize=size(c);
for i=1:Csize(2)
if(c(i)>100)
c(i)=2*c(i);
else
c(i)=0.5*c(i);
end
end
x=waverec2(c,l,'sym4');
imshow(x);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function xianxing_Callback(hObject, eventdata, handles)
% hObject handle to xianxing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=imadjust(x,[0 1],[1 0],1.5);
imshow(y);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function feixianxing_Callback(hObject, eventdata, handles)
% hObject handle to feixianxing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=(handles.img);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
y=double(x);
n=0.05*log(y+1);
imshow(n);
set(handles.axes2,'HandleVisibility','OFF');
% --------------------------------------------------------------------
function hdbianhuan_Callback(hObject, eventdata, handles)
% hObject handle to hdbianhuan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function ellip_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
%椭圆低通滤波器
Wp=0.26;Ws=0.51;Rp=3;Rs=8;
[N1,Wn1] = ellipord(Wp,Ws,Rp,Rs);
[num,den]=ellip(N1,Rp,Rs,Wn1);
dhL(1:M,1:N,o)=AL(1:M,1:N);
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to ellip (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function cheby2_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Wp=0.25;Ws=0.72;Rp=4;Rs=10;
[N1,Wn1] = cheb2ord(Wp,Ws,Rp,Rs);
[num,den]=cheby2(N1,Rp,Wn1)
dhL(1:M,1:N,o)=AL(1:M,1:N);
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to cheby2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function cheby1_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
%切比雪夫1型低通滤波器
Wp =0.27;Ws =0.52;Rp =4;Rs =9;
[N2,Wn2] = cheb1ord(Wp,Ws,Rp,Rs);
[num,den] =cheby1(N2,Rp,Wn2,'low');
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to cheby1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
%切比雪夫1型低通滤波器
Wp =0.27;Ws =0.52;Rp =4;Rs =9;
[N2,Wn2] = cheb1ord(Wp,Ws,Rp,Rs);
[num,den] =cheby1(N2,Rp,Wn2,'low');
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function firlvboqi_Callback(hObject, eventdata, handles)
% hObject handle to firlvboqi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function blackman_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1300;Fs=7500;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+18;
taper=blackman(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to blackman (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function hamming_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1300;Fs=6900;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+8;
taper=hamming(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to hamming (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function hanning_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1600;Fs=7200;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+5;
taper=hanning(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to hanning (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function cheby_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1600;Fs=7200;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+24;
taper=chebwin(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to cheby (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function kaiser_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=2000;Fs=6800;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+3;
taper=kaiser(N+1,beta);
num=fir1(N,Wn,ftype,taper);
den=1;
for k=1:N
x=AL(:,k);
AL(:,k)=filter(num,den,x);%设计出的IIR滤波器的参数num,den
end
dhL(1:M,1:N,o)=AL(1:M,1:N);
%按行处理
for i=1:M
y=AI(i,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
dhI(1:M,1:N,o)=AI(1:M,1:N);
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to kaiser (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function battlet_Callback(hObject, eventdata, handles)
x=(handles.img);
x=double(x);
axes(handles.axes2);
set(handles.axes2,'HandleVisibility','ON');
[M,N,O]=size(x);
dh=x;
dhL=x;
dhI=x;
for o=1:3
A(1:M,1:N)=dh(1:M,1:N,o);
AL=A;
AI=A;
%用设计的滤波器对图象滤波
%按列处理;
Fp=1600;Fs=7200;Rp=0.5;Rs=30;
FT=5*Fs;
Wp=2*Fp/FT;Ws=2*Fs/FT;
dp=1-10^(-Rp/20);ds=10^(-Rs/20);
[N Wn,beta,ftype]=kaiserord([Fp Fs],[1 0],[dp ds],FT);
%[N Wn]=kaiord(Fp,Fs,dp,ds,FT);
N=N+138;
taper=bartlett(N+1);
num=fir1(N,Wn,ftype,taper);
den=1;
%按行处理
for i=1:M
y=AI(i,:,:);
AI(i,:)= filter(num,den,y);%设计出的IIR滤波器的参数num,den
end
MA=max(max(AI)');
dhI(1:M,1:N,o)=AI(1:M,1:N)/MA;
%行列终和
DH(1:M,1:N,o)=(dhI(1:M,1:N,o)+dhL(1:M,1:N,o))/2;
% DH(1:M,1:N,o)=dhL(1:M,1:N,o);
%有约束滤波
% DH(:,:,1)=DH(:,:,1)+0.03;%加暖色
% DH(:,:,2)=DH(:,:,2)+0.03;
%DH(:,:,3)=DH(:,:,3);
DH=uint8(DH);
end
figure();imshow(DH);
set(handles.axes2,'HandleVisibility','OFF');
% hObject handle to cheby1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
相关文章推荐
- 基于Matlab的图像处理GUI
- 基于matlab的数字图像处理GUI设计
- 基于MATLAB GUI的图像处理软件平台的开发(转自深寒的博客)
- 基于MATLAB图像处理工具箱
- 基于Opencv3和Qt5的图像处理GUI
- 基于matlabGUI的语音处理
- Matlab图像处理学习笔记(二):基于颜色的图像分割
- 基于MATLAB的储粮害虫图像处理方法
- Matlab GUI 图像识别与图像处理
- 基于MATLAB图像处理工具箱
- MATLAB GUI 打开/显示/处理 /保存/图象(图像)程序
- 基于matlab-GUI数字音频处理系统(二)
- MATLAB GUI实现常见图像处理算法与视频跟踪算法
- 基于MATLAB的数字图像处理之直方图处理
- 基于Matlab的图像分块处理
- Matlab图像处理学习笔记(三):基于匹配的目标识别
- MATLAB中GUI图像处理
- 基于matlab图像锐化处理
- 数字图像处理——Matlab GUI与灰度变换函数
- 基于MATLAB图像处理工具箱