数字图像处理与分析实验
第1章:编写程序
任务:使用章节所学知识编写一个程序。要求:1,具有读取和保存图像的功能;
2.可对图像进行16、64和128个灰度级的量化;
3.具有交互界面,
第2章:编写空域图像增强程序
任务:使用章节所学知识编写一个空域图像增强程序,对输入图像进行空域图像
增强并输出相应结果。
要求;1.可进行6种点运算、8种代数运算、直方图运算;
2.使用线性和非线性平滑滤波器;
3.使用一阶微分和二阶微分锐化滤波器;
4.具有交互界面;
5.不可调用系统函数。第3章:编写彩色图像处理程序
任务:使用章节所学知识编写一个彩色图像处理程序,对输入图像进行相应处理
并输出结果。
要求:1.至少实现4种彩色空间的互转;
2.具有补色、灰度变换、直方图均衡化的功能;
3.具有交互界面;
4.不可调用系统函数。第4章:编写傅里叶变换程序
任务:使用章节所学知识编写一个傅里叶变换程序,对输入图像进行傅里叶变换
并输出相应结果。
要求:1.可进行傅里叶变换和反变换;
2.可进行快速傅里叶变换和反变换;
3.具有交互界面;
4.不可调用系统函数。第5章:编写频域图像增强程序
任务:使用章节所学知识编写一个频域图像增强程序,用频域方法增强输入图像
并输出相应结果,
要求:1.至少使用2种频域平滑滤波器;
2.至少使用2种频域锐化滤波器;
3.具有交互界面;
4.不可调用系统函数。第6章:编写图像复原程序
任务:使用章节所学知识编写一个图像复原程序,复原输入图像并输出相应结果。要求:1.至少对图像加3种噪声;
2.至少使用5种空间滤波器;
3.使用带阻、带通、陷波3种频率滤波器;
4.具有交互界面;
5.不可调用系统函数。第7章:编写图像压缩程序
任务:使用章节所学知识编写一个图像压缩程序,压缩输入图像并输出相应结果。要求:1.使用霍夫曼、算术、LZW、位平面中的2种编码完成无损压缩;
2.使用DFT、WHT、DCT中的2种变换完成有损压缩;
3.具有压缩和复原的功能;
4.具有交互界面:
5.不可调用系统函数。第8章;编写形态学处理程序
任务:使用章节所学知识编写一个形态学处理程序,对输入图像进行形态学处理
并输出相应结果。
要求:1.具有膨胀与腐蚀功能;
2.可进行开操作和闭操作;
3.可进行边界提取和区域填充;
4.具有交互界面;
5.不可调用系统函数。第9章:编写分割程序
任务:使用章节所学知识编写一个分割程序,分割输入图像并输出相应结果。要求:1.包含基于区域灰度不连续、基于像素阈值、基于区城三种方法;
2.至少使用 2种算子进行边缘检测;
3.具有交互界面;
4.不可调用系统函数。第10章:编写表示与描述程序
任务;使用章节所学知识编写一个表示与描述程序,根据输入图像完成相关表示
和描述,并输出相应结果。要求:1.至少使用3种表示方法;
2.至少使用 2种边界描述子;
3.至少使用 2种关系描述子
4.具有交互界面;
5.不可调用系统函数。第11章:编写图像检索程序
任务:使用章节所学知识编写一个图像检索程序,根据输入图像查找并输出相应
结果。
要求:1.至少使用2种特征提取方法;
2.至少使用 2种相似度匹配方法;
3.具有交互界面;
4.不可调用系统函数。第12章:编写综合实践系统
任务:使用课程所学知识编写一个课程设计的综合系统。要求:1.具有交互界面;
2.集成1-11章的实践实验于一个系统。
如有问题可私信讨论或qq:2597428349
function varargout = importpicture(varargin)
% IMPORTPICTURE MATLAB code for importpicture.fig
% IMPORTPICTURE, by itself, creates a new IMPORTPICTURE or raises the existing
% singleton*.
%
% H = IMPORTPICTURE returns the handle to a new IMPORTPICTURE or the handle to
% the existing singleton*.
%
% IMPORTPICTURE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in IMPORTPICTURE.M with the given input arguments.
%
% IMPORTPICTURE('Property','Value',...) creates a new IMPORTPICTURE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before importpicture_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to importpicture_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help importpicture
% Last Modified by GUIDE v2.5 22-Nov-2023 21:12:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @importpicture_OpeningFcn, ...
'gui_OutputFcn', @importpicture_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
end
% --- Executes just before importpicture is made visible.
function importpicture_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 importpicture (see VARARGIN)
% Choose default command line output for importpicture
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes importpicture wait for user response (see UIRESUME)
% uiwait(handles.figure1);
end
% --- Outputs from this function are returned to the command line.
function varargout = importpicture_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;
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)%导入图片按钮
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, filepath]=uigetfile({'*.png;*.jpg;*.jpeg'},'选择图片文件');
set(handles.text2,'string',[filepath filename])
% 打开文件对话框,返回相应格式文件的名称和路径
if isequal(filename,0)||isequal(filepath,0)
% 若未选择到图片
errouglg('没有选中文件,请重新选择');
% 弹窗提示
return;
else
str=[filepath filename];
set(handles.text2,'string',str)
% 若选择成功,就将edit1的string文本设置为选择文件的路径和名称
end
% 复制文本路径
road=get(handles.text2,'string');
% 获取文本路径
handles.road=road;
guidata(hObject,handles);
axes(handles.axes2);%清除第二个坐标轴上的图像
cla reset;
road=handles.road;%获取存储的路径
axes(handles.axes1);%在第一个坐标轴上显示原图像
imshow(road);
end
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName,PathName] = uiputfile({'*.jpg','JPEG(*.jpg)';...
'*.bmp','Bitmap(*.bmp)';...
'*.gif','GIF(*.gif)';...
'*.*', 'All Files (*.*)'},...
'Save Picture','Untitled');
if FileName==0
return;
else
h=getframe(handles.axes2);
imwrite(h.cdata,[PathName,FileName]);
end
end
% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)%量化
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu4
var = get(handles.popupmenu4,'Value');
switch (var)
case 1 % 选中第一行
road=get(handles.text2,'string');
img=imread(road);
t1=rgb2gray(img);
t2=histeq(t1,16);
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像% 绘制图像,线宽为2,蓝色
case 2 % 选中第二行
road=get(handles.text2,'string');
img=imread(road);
t1=rgb2gray(img);
t2=histeq(t1,64);
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像
case 3 % 选中第三行
road=get(handles.text2,'string');
img=imread(road);
t1=rgb2gray(img);
t2=histeq(t1,128);
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像
end
end
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
% --- Executes on selection change in popupmenu5.
function popupmenu5_Callback(hObject, eventdata, handles)%点运算
% hObject handle to popupmenu5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu5 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu5
var = get(handles.popupmenu5,'Value');
switch (var)
case 1 % 选中第一行
road=get(handles.text2,'string');
img=imread(road);
t2 = img+50;
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像% 绘制图像,线宽为2,蓝色
case 2 % 选中第二行
road=get(handles.text2,'string');
img=imread(road);
t2 = img+100;
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像
case 3 % 选中第三行
road=get(handles.text2,'string');
img=imread(road);
t2 = img-50;
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像
case 4 % 选中第三行
road=get(handles.text2,'string');
img=imread(road);
t2 = img*1.2;
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像
case 5 % 选中第三行
road=get(handles.text2,'string');
img=imread(road);
t2 = img*0.65;
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像
case 6 % 选中第三行
road=get(handles.text2,'string');
img=imread(road);
t2 = -double(img)+255;
axes(handles.axes2);%第二个坐标轴
imshow(t2);%显示图像
end
end
% --- Executes during object creation, after setting all properties.
function popupmenu5_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
% --- Executes on selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)%均值与非均值滤波
% hObject handle to popupmenu6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu6 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu6
var = get(handles.popupmenu5,'Value');
switch (var)
case 1 % 选中第一行
road=get(handles.text2,'string');
f=imread(road);
[m,n,z]=size(f);
f1=imnoise(f,'gaussian',0,0.02);
f1= rgb2gray(f1);
f2=f1;
for i=1:m-2
for j=1:n-2
f2(i+1,j+1,:)=round(f2(i,j,:)/9+f2(i,j+1,:)/9+f2(i,j+2,:)/9+f2(i+1,j,:)/9+f2(i+1,j+1,:)/9+f2(i+1,j+2,:)/9+f2(i+2,j,:)/9+f2(i+2,j+1,:)/9+f2(i+2,j+2,:)/9);
end
end
axes(handles.axes2);%第二个坐标轴
imshow(f2);%显示图像
% case 2 % 选中第二行
% road=get(handles.text2,'string');
% img=imread(road);
% axes(handles.axes2);%第二个坐标轴
% imshow(I0);%显示图像
case 2 % 选中第三行
road=get(handles.text2,'string');
f=imread(road);
[m,n,z]=size(f);
f1=imnoise(f,'gaussian',0,0.02);
f1= rgb2gray(f1);
f2=f1;
for i=1:m-2
for j=1:n-2
temp=[f2(i,j,:),f2(i,j+1,:),f2(i,j+2,:),f2(i+1,j,:),f2(i+1,j+2,:),f2(i+2,j,:),f2(i+2,j+1,:),f2(i+2,j+2,:),f2(i+1,j+1,:)];
temp=sort(temp);
f2(i+1,j+1,:)=temp(5);
end
end
axes(handles.axes2);%第二个坐标轴
imshow(f2);%显示图像
% case 4 % 选中第三行
% road=get(handles.text2,'string');
% img=imread(road);
% t2 = img*1.2;
% axes(handles.axes2);%第二个坐标轴
% imshow(t2);%显示图像
end
end
% --- Executes during object creation, after setting all properties.
function popupmenu6_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end