数字图像处理完整MATLAB代码在我的资源可以看到,为方便下载,下面是百度网盘资源:
链接:https://pan.baidu.com/s/17S7PZJwwvb3PFMFVxqEY5w
提取码:HUAT
1.首先在MATLAB命令行窗口输入guide,然后回车运行,会弹出GUI设计窗口。
2.点击ActiveX控件,在GUI栅格界面左键单击一次,会弹出选择页面,选择Windows Media Player,点击创建,然后再在GUI栅格界面创建一个静态文本,调整两者大小。
3.双击静态文本,修改 FontSize为30.0,修改String为歌曲名称,修改Tag为txt_mp3
4.点击菜单编辑器,分别创建“选择播放文件”和“开始播放”两个菜单,并作如下修改。另存为为MP3.fig,至此GUI界面设计完成。
4.将如下代码覆盖进MP3.m文件中(代码十分简单,已做标注解释)
function varargout = MP3(varargin)
% MP3 MATLAB code for MP3.fig
% MP3, by itself, creates a new MP3 or raises the existing
% singleton*.
%
% H = MP3 returns the handle to a new MP3 or the handle to
% the existing singleton*.
%
% MP3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MP3.M with the given input arguments.
%
% MP3('Property','Value',...) creates a new MP3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before MP3_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to MP3_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 MP3
% Last Modified by GUIDE v2.5 15-Mar-2023 15:33:47
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @MP3_OpeningFcn, ...
'gui_OutputFcn', @MP3_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 MP3 is made visible.
function MP3_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 MP3 (see VARARGIN)
% Choose default command line output for MP3
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes MP3 wait for user response (see UIRESUME)
% uiwait(handles.MP3);
% --- Outputs from this function are returned to the command line.
function varargout = MP3_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function m_file_mp3_Callback(hObject, eventdata, handles)
% hObject handle to m_file_mp3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global abc;%全局变量用于传递MP3文件数据
[FileName,PathName] = uigetfile('*.mp3','Select mp3 File');%用于选择打开MP3文件
abc = fullfile(PathName,FileName);%将文件数据传递给abc变量
set(handles.txt_mp3,'String',FileName);%将MP3文件名称在静态文本上显示
% --------------------------------------------------------------------
function m_play_mp3_Callback(hObject, eventdata, handles)
% hObject handle to m_play_mp3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global abc;
set(handles.activex1,'URL',abc);%在activex1控件上播放MP3文件