【手势识别】基于matlab图像处理的手势识别系统【源码61期】

一、简介

基于matlab图像处理的手势识别系统,本文介绍了MATLAB手势识别的基本原理、实现方法以及在各个领域的应用案例,展望了未来发展趋势,旨在为相关领域的研究者提供参考和启示。介绍手势识别的概念、重要性和应用领域,引出MATLAB手势识别的研究意义和应用价值。

二、部分源码


function button_catch_Callback(hObject, eventdata, handles)
global obj;
catch_pic=getsnapshot(obj);%摄取图像
catch_pic=imresize(catch_pic,[240, 320]);  %统一图片大小
axes(handles.axes2);
imshow(catch_pic);%在axes2显示摄取的图片
setappdata(gcf,'pic',catch_pic);%把catch_pic变成全局变量
function button_cut_Callback(hObject, eventdata, handles)
pic = getappdata(gcf,'pic'); %获取全局变量
l = get(handles.popupmenu_choose,'value'); %获取下拉菜单选中项
if l==1  %基于YCgCr肤色分割(适用于较复杂背景)
    pic_cut = colour_cut(pic);
end
axes(handles.axes3);
imshow(pic_cut);
setappdata(gcf,'pic_cut',pic_cut);%把catch_pic变成全局变量
function popupmenu_choose_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function pushbutton_open_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile( ...
{'*.bmp;*.jpg;*.fig;*.tif','MATLAB Files (*.bmp;*.jpg;*.fig;*.tif)';
   '*.*',  'All Files (*.*)'}, ...
   'Pick a file');
pic=imread([pathname,filename]);%读取图片给im
pic=imresize(pic,[240, 320]);  %统一图片大小
axes(handles.axes2);
imshow(pic);%在axes2显示摄取的图片
setappdata(gcf,'pic',pic);%把pic变成全局变量
function pushbutton_denoise_Callback(hObject, eventdata, handles)
pic_cut = getappdata(gcf,'pic_cut'); %获取全局变量
pic_denoise = denoise(pic_cut);
axes(handles.axes4);
imshow(pic_denoise);
setappdata(gcf,'pic_denoise',pic_denoise);%把pic变成全局变量
function popupmenu_operator_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function pushbutton_edge_Callback(hObject, eventdata, handles)
%轮廓图像
pic = getappdata(gcf,'pic_denoise'); %获取全局变量
l = get(handles.popupmenu_operator,'value'); %获取下拉菜单选中项
if l == 1  %Sobel算子
    pic_edge = edge(pic,'sobel');
end
if l == 2 %Prewitt算子
    pic_edge = edge(pic,'prewitt');
end
if l == 3 %Roberts算子
    pic_edge = edge(pic,'roberts');
end
if l == 4 %log算子
    pic_edge = edge(pic,'log');
end
if l == 5 %Canny算子
    se=fspecial('gaussian',5); %高斯滤波
    pic=imfilter(pic,se);
    pic_edge = edge(pic,'canny');
end
[r c]=find(pic_edge==1);  
% 'a'是按面积算的最小矩形,如果按边长用'p'  
[rectx,recty,area,perimeter] = minboundrect(c,r,'p');   
axes(handles.axes5);
imshow(pic_edge);
hold on  
line(rectx,recty); 
setappdata(gcf,'pic_edge',pic_edge);%把pic_edge变成全局变量

% --- Executes on button press in pushbutton_feature.
function pushbutton_feature_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_feature (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
pic = getappdata(gcf,'pic_edge'); %获取全局变量
feature=fourierdescriptors(pic); %对轮廓图提取傅里叶描述子2-8共7个系数
Hu = Humoment(pic); %对轮廓图像提取Hu矩特征
fdedit = ['傅里叶描述子:',10];
huedit = [10,'Hu矩特征:',10];
for i = 1:7
    fdedit = [fdedit,[num2str(feature(i)),10]];
    huedit = [huedit,[num2str(Hu(i)),10]];
end
set(handles.edit_feature,'string',strcat(fdedit,huedit));
Allfeature = [feature,Hu];
setappdata(gcf,'feature',Allfeature);

% --- Executes on button press in pushbutton_result.
function pushbutton_result_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_result (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
feature = getappdata(gcf,'feature');
if isempty(feature)
    msgbox('请先提取手势图像特征值!', '提示');
else
    flag = exist('data.mat','file'); %判断文件是否存在
    if flag == 0 %文件不存在
        msgbox('未找到手势模板特征库!', '提示');
    else
        all = load('data.mat'); %加载mat文件
        names = fieldnames(all); % 获取mat中所有变量的名字
        data = all.(names{1}); %把第一个变量赋给before
        [row,col] = size(data);
        results = zeros(row,2);
        for i = 1:row;
            results(i,1) = ModHausdorffDist(feature,data(i,1:col-1));
            results(i,2) = data(i,col);
        end
    end
    [m,row] = min(results,[],1);
    result = results(row(1,1),2);
    set(handles.edit_result,'string',num2str(result));
    data = [feature,result];
    setappdata(gcf,'data',data);
end

三、运行结果

四、matlab版本

MATLAB R2019a

五、学习与交流

文中不足之处请大家多多指教,学习与交流可以联系企鹅:3752243968
文中部分源码仅供参考,若需要全部代码可以私信

  • 13
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
matlab可以用于图像处理,在图像处理可以实现多种操作,例如平移、镜像、放大、缩小和旋转等。在给定的引用,介绍了如何使用matlab在hfss建模以及如何在matlab执行平移和旋转操作。 对于平移操作,可以使用以下代码实现: ``` matlab I = imread('D:\Backup\Documents\My Pictures\Saved Pictures\picture1.jpg'); [M, N, C] = size(I); g = zeros(M, N, C); for color = 1:3 for i = 1:M for j = 1:N newx = i + 30; newy = j + 30; if (newx <= M) && (newy <= N) g(newx, newy, color) = I(i, j, color); end end end end imshow(uint8(g)); ``` 这段代码可以将图像向右下方平移30个像素。 对于旋转操作,可以使用以下代码实现: ``` matlab im = imread('D:\Backup\Documents\My Pictures\Saved Pictures\picture1.jpg'); a = 30 / 180 * pi; % 旋转角度 R = [cos(a), -sin(a); sin(a), cos(a)]; % 旋转矩阵 R = R'; sz = size(im); h = sz(1); w = sz(2); ch = sz(3); c1 = [h; w] / 2; hh = floor(w * sin(a) * h * cos(a)) - 1; ww = floor(w * cos(a) * h * sin(a)) - 1; c2 = [hh; ww] / 2; im2 = uint8(ones(hh, ww, 3) * 128); % 初始化目标画布 for k = 1:ch for i = 1:hh for j = 1:ww p = [i; j]; pp = (R * (p - c2) + c1); mn = floor(pp); ab = pp - mn; a = ab(1); b = ab(2); m = mn(1); n = mn(2); if (pp(1) >= 2 && pp(1) <= h-1 && pp(2) >= 2 && pp(2) <= w-1) im2(i, j, k) = (1-a)*(1-b)*im(m, n, k) + a*(1-b)*im(m+1, n, k) + (1-a)*b*im(m, n+1, k) + a*b*im(m+1, n+1, k); end end end end imshow(im2); ``` 这段代码可以将图像顺时针旋转30度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值