精华内容
下载资源
问答
  • 本课题为基于matlab的人数统计系统。近年来,很多行业对人流信息有极大的需求,如汽车公交站,地铁站台,商场出入口等。通过人数统计系统可以方便、可靠、实时地对各种场所的人流进行统计,而不对公众造成任何影响。...

    一、简介

    1 课题背景
    本课题为基于matlab的人数统计系统。近年来,很多行业对人流信息有极大的需求,如汽车公交站,地铁站台,商场出入口等。通过人数统计系统可以方便、可靠、实时地对各种场所的人流进行统计,而不对公众造成任何影响。结合其他图像分析技术,系统可以清楚快捷地掌握客流动态,提供数据支持,使决策者及时做出对策。利用图像处理来完成人数统计系统的主要优点就是图像信号非常直观,便于人为的理解。可以看出,图像的人数统计无论是在商业信息采集还是公共安全监控方面具有重要意义,图像的人数统计识别算法的研究无论在理论上还是在实际应用领域都有着诱人的发展前景。
    2 课题分析
    以往老师统计学生出勤情况基本上靠人工点名,但是这种方法往往会浪费大量的时间,效率低下,不是一个好的选择。本课题,基于MATLAB的教室人数统计,带有丰富的人机交互GUI界面。实现教室人数的计数统计,进而统计出勤率,上课认真听讲的比例。原先预设总人数,未出勤或者书本遮住脸部、趴着玩手机等必然无法采集到人脸,从而对应数量缺失,得出出勤率或听讲率。该课题采用肤色原理进行人脸定位和人脸分割。本课题中,为了界面GUI的美观,刻意将分割出的人脸单独显示在GUI对应的axes里。
    3 社会需求分析
    (1)对同学来说:脱离高中魔鬼式的学习,迈入高校的殿堂,许多在校大学生作息时间紊乱,课堂到课情况不理想。出现缺课、旷课情况,严重影响到学业成绩。更有少数学生利用上课时间出去游玩,发生意外。让学生养成一个好的作息习惯,规范学生的考勤,是很多高校最想做到的事情之。因此,快速、有效的出勤统计对大学生的学习以及学习至关重要。
    对老师来说:统计出勤情况是记录学生课程学习过程、提供平时成绩评定依据、减少学生发生意外的风险的有效方法。而传统考察出勤人数的方式大多耗时费力,在浪费宝贵课堂时间的同时,也为老师增添了负担。
    4 为了说明开发本项目—教室人员统计系统的必要性,我们对传统的考察出勤人数方式进行了分析。
    (a)花名册顺序点名
    教师或者教师让一名学生使用花名册进行顺序点名。
    优点:每一名学生都要答到,教师可以有更多的机会认识每一位同学,比较真实的反应了学生的到课情况。
    缺点:如果学生的人数比较多,会浪费学生和老师很多的宝贵时间,并且,存在其他同学帮忙答到的情况。
    (b)花名册随机点名
    教师第一次上课时,使用花名册进行顺序点名,未到的同学做好标记。下次上课的时候先点前几次未到的同学,然后再随机点几名同学。
    优点:随机点名法节省了大量的时间,给那些点名未到的同学施加适当的压力,班级旷课的同学基本.上都是“老面孔”,这种方法可以让那些同学不敢再旷课。
    缺点:第一次点名仍然要花费大量的时间,随机点名法存在很多“运气”成份,可能会有一些同学经常没来.上课,但没有被发现。
    ©固定座位
    让所有的学生靠前坐,并给班级的每位学生固定座位,上课后,统计缺席人员名单。
    优点:老师在上课的时候,可以清楚地看到学生的出勤情况。学生座位靠近讲台,可以提高学生的上课注意力。
    缺点:高校学生上课要经常更换教室,固定座位的做法,随着教室的变动会带来很多不便。
    (d)分组统计
    将班级的学生分为多个小组,每个组选出一一个小组长,由小组长确定小组人员的到课情况,下课后, 小组长将名单交给老师。
    优点:节省了老师的时间,便于进行以小组为单位的讨论和学习。
    缺点:可能会存在小组长包庇组员的情况,教师无法确定学生的真实出勤率。
    4 为了了解大学生对本项目—教室人员统计系统的接受度,我们使用问卷星对大一至大四的在读本科生进行了问卷调查。以下为调查结果分析:
    调查结果显示被调查者在校期间考察出勤的方式中传统点名占72.13%,软件签到占19.03,其他占9.84%。由此可见传统点名占占据考察方式的大多数,仍没有可以完全取代它的方式出现。
    对于本项目中通过老师拍照的方式统计出勤人员可能涉及肖像权的问题,仅有9.67%人会有些介意,49.34%完全不在意。而更多则是没考虑过这个这问题,占总人数的40.98%。 由此可见忽略极少部分,可以认为通过拍照方式统计人数可以被大多数人接受。
    被问及此项目优缺点时,认为这种方式速度快的占参与者的57.38%,方便占30.17%,其它占12.45%。而他们担心的问题中担心统计不准切导致“被”缺勤占比最高达83.61%。
    综上调查,我们认为目前需要一种比传统点名更高效的方式出现。此项目正是想要弥补这一空缺。而提高系统性能,减少差错的出现是增强教室人员统计系统实用性的关键。
    5 计算机视觉系统工具箱简介
    计算机视觉系统工具箱(Computer Vision System Toolbox,CVST)是Matlab2012b版本自带工具箱。该工具箱不仅包括用于特征提取、运动检测、目标检测、目标跟踪、立体视觉、视频处理、视频分析的算法,还包括视频文件输入输出,视频显示,绘图以及合成。这些功能以Matlab函数、Matlab系统对象、Simulink块的形式提供。对于快速原型和嵌入式系统设计,该工具箱支持定点算法和C代码产生。
      计算机视觉系统工具箱的人脸检测算法主要基于Viola-Jones的人脸检测,通过内置的类和函数进行人脸甚至是鼻子、嘴以及眼睛的自动检测。Viola-Jones人脸检测是Paul viola 和 Michael J Jones共同提出的一种人脸检测算法,该算法原理简单,耗费资源小,在提出后被广泛用于人脸检测。Viola-Jones人脸检测主要包含Haar-like特征、积分图、AdaBoost迭代算法和级联分类器等内容,实现人脸检测的主要步骤是:①利用Haar-like矩形特征表征人脸,使用“积分图”对图像中的矩形特征进行快速计算。②利用AdaBoost算法从数量巨大的Haar-like特征中训练出人脸检测所需要的分类器。③将训练得到的强分类器进行级联,利用级联的强分类器构成最终的分类器。
      计算机视觉系统工具箱只需要用简单的命令即可实现人脸检测。调用工具箱中的vision.CascadeObjectDetector即可运行。不仅运行速度较快,且人脸检测准确度很高。经过自行改进,可进行批处理。

    6 方案设计
    6.1框架设计
    该项目要完成的功能是:根据所给的图片,实现自动人脸检测,人数统计,要求含有GUI界面,且算法能够准确的实现人数的统计,拥有较快的运算速度,具有较好的实时性。

    6.2界面设计
    首先,将页面背景设置为灰白色,在中心及偏左页面设置两个坐标系axes1以及axes2,用以显示后来选中的图片和人脸识别后已框出人脸的图片。在坐标系右边从上到下依次拖拽设置pushbutton1、pushbutton2、edit1、text1、pushbutton2。其中,pushbutton1上编辑‘打开教室图片’字样,用以完成打开图片功能;edit1上编辑‘统计结果’字样;text4中显示‘统计结果’的结果;pushbutton2上编辑‘统计人数’,通过点击此按钮实现统计人数的功能;最后一个pushbutton3上编辑‘完成’字样,完成关闭功能。坐标轴上方还设置一个text2,编辑‘欢迎使用教室人数统计系统’作为标题。至此完成页面的界面设计。
    在这里插入图片描述

    6.3功能设计
    对于pushbutton1按钮,即点击‘打开教室图片’,是使用uigetfile函数标准化打开选择文件对话框,此时会弹出此电脑的文件界面,选择一张带有人的图片后,点击确认即可在axes1上显示该选中图片,且在此图片上方设置标题‘教室照片’,完成选中图片功能。其次点击‘统计人数’按钮,在代码中取得打开图片的相关数据,将彩色图像转化为灰度图像等等处理,设置路径将此转化处理后的图像显示在axes2,此外还可找到图片中的人脸,绘制边框圈出来,统计出边框的个数反映在text1中,且在此图像上方设置标题‘框出人脸区域’。至此完成此设计的全部功能。下图为该项目的功能流程图:
    在这里插入图片描述
    图1 功能流程图

    二、源代码

    function varargout = face_collection(varargin)
    % FACE_COLLECTION MATLAB code for face_collection.fig
    %      FACE_COLLECTION, by itself, creates a new FACE_COLLECTION or raises the existing
    %      singleton*.
    %
    %      H = FACE_COLLECTION returns the handle to a new FACE_COLLECTION or the handle to
    %      the existing singleton*.
    %
    %      FACE_COLLECTION('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in FACE_COLLECTION.M with the given input arguments.
    %
    %      FACE_COLLECTION('Property','Value',...) creates a new FACE_COLLECTION or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before face_collection_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to face_collection_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 face_collection
    
    % Last Modified by GUIDE v2.5 13-A-2021 12:23:11
    
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @face_collection_OpeningFcn, ...
                       'gui_OutputFcn',  @face_collection_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 face_collection is made visible.
    function face_collection_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 face_collection (see VARARGIN)
    
    % Choose default command line output for face_collection
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    
    % UIWAIT makes face_collection wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = face_collection_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 edit2_Callback(hObject, eventdata, handles)
    % hObject    handle to edit2 (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,'String') returns contents of edit2 as text
    %        str2double(get(hObject,'String')) returns contents of edit2 as a double
    
    
    % --- Executes during object creation, after setting all properties.
    function edit2_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to edit2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
    
    % Hint: edit 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
    
    % --- 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)
    global I
    [x,y,c]=ginput(2);
    if c==1
        BB=imcrop(I,[min(x(1),x(2)),min(y(1),y(2)),abs(x(2)-x(1)),abs(y(2)-y(1))]);
        BB=imresize(BB,[252 202]);
        axes(handles.axes2); % 处理后的图像放在axes2中
        imshow(BB)
    end
    
    
    
    function edit1_Callback(hObject, eventdata, handles)
    % hObject    handle to edit1 (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,'String') returns contents of edit1 as text
    %        str2double(get(hObject,'String')) returns contents of edit1 as a double
    
    
    % --- Executes during object creation, after setting all properties.
    function edit1_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to edit1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
    
    % Hint: edit 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
    
    
    % --- Executes on button press in pushbutton2.
    function pushbutton2_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    [filename, pathname] = uigetfile( ...
    {'*.jpg;*.png;*.jpeg', 'Image Files (*.bmp;*.jpg;*.png;*.jpeg)'; ...
    '*.*', 'All Files (*.*)'}, ...
    'Pick an image');
    if isequal(filename,0) || isequal(pathname,0),
    return;
    end
    

    三、运行结果

    在这里插入图片描述
    在这里插入图片描述

    四、备注

    完整代码或者代写添加QQ 1564658423

    展开全文
  • 基于matlab GUI 灰度、二值、腐蚀、直方图处理之水果识别 二、源代码 function varargout = untitled(varargin) % UNTITLED MATLAB code for untitled.fig % UNTITLED, by itself, creates a new UNTITLED or ...

    一、简介

    基于matlab GUI 灰度、二值化、腐蚀、直方图处理之水果识别

    二、源代码

    function varargout = untitled(varargin)
    % UNTITLED MATLAB code for untitled.fig
    %      UNTITLED, by itself, creates a new UNTITLED or raises the existing
    %      singleton*.
    %
    %      H = UNTITLED returns the handle to a new UNTITLED or the handle to
    %      the existing singleton*.
    %
    %      UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in UNTITLED.M with the given input arguments.
    %
    %      UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before untitled_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to untitled_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 untitled
    
    % Last Modified by GUIDE v2.5 15-Jan-2017 01:03:42
    
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @untitled_OpeningFcn, ...
                       'gui_OutputFcn',  @untitled_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 untitled is made visible.
    function untitled_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 untitled (see VARARGIN)
    
    % Choose default command line output for untitled
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    
    % UIWAIT makes untitled wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = untitled_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 on button press in pushbutton3.
    function pushbutton3_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton3 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    global I FilledLabel HSV MeanHue  Ecllipseratio Label num Premeter Area
     for i = 1 : num
            Premeter(i) = 0;
        end
    
        [row,col] = size(Label);
        for i = 1 : row
            for j = 1 : col
                if(Label(i,j) > 0)
                    Premeter(Label(i,j)) = Premeter(Label(i,j)) + 1;    %计算标记后的各块图形边界中像素的个数的总数
                end
            end
        end
    
    %计算各个图形单元的面积
    FilledLabel=imfill(Label,'holes');  %填充打过标记的边界线中间围成的图形区域
    for i = 1 : num
        Area(i) = 0;
    end
    
    [row,col] = size(FilledLabel);
    for i = 1 : row
        for j = 1 : col
            if(FilledLabel(i,j) > 0)
                Area(FilledLabel(i,j)) = Area(FilledLabel(i,j)) + 1;   %通过统计像素点个数的方式来求各形状的面积
            end
        end
    end
    
    %计算各个图形单元的圆度
    for i = 1 : num     
        Ecllipseratio(i) = 4*pi*Area(i)/Premeter(i)^2;
    end
    
    %计算各个图像的颜色(色度)
    
    HSV=rgb2hsv(I);   %转换为HSV,为后面的颜色元素的提取做准备
    
    [row,col] = size(FilledLabel);   %统计填充后的图形中各块图形所含像素的个数的多少
    MeanHue = zeros(1,num);
        for i = 1 : num
            Hue = zeros(Area(i),1);
            nPoint = 0;
            for j = 1 : row
                for k = 1 : col
                    if(FilledLabel(j,k) == i)
                        nPoint = nPoint + 1;
                        Hue(nPoint,1) = HSV(j,k,1);
                    end
                end
            end
            
            Hue(:,i) = sort(Hue(:,1));
            for j = floor(nPoint*0.1) : floor(nPoint*0.9)
                MeanHue(i) = MeanHue(i) + Hue(j,1);
            end
            MeanHue(i) = MeanHue(i) / (0.8*nPoint);  %计算出平均的色度值
        end
    %识别菠胡萝卜
    
    %构建胡萝卜的分类器,在二维特征空间对各个图像进行类别区分
    huluobo=1;
    mazarea=Area(1);
    for i=1:num
        if(mazarea<Area(i))%分类器识别桃的准则:判断各个图形中面积最大的为胡萝卜
            mazarea=Area(i);
            huluobo=i;
        end
    end
    %对分出来的类别分别构建相应的图像掩膜,并用对原图的亮度图像进行掩膜操作
    huluoboHSV=HSV;
            for j = 1 : row
                for k = 1 : col
                    if(FilledLabel(j,k) ~=huluobo)
                           %huluoboHSV(j,k,2)=0;
                           huluoboHSV(j,k,3)=0;
                    end
                end
            end
    %变换生成最终的结果图像,图像中显示的结果即对应分类器中指定的类别
    huluobomatrix = hsv2rgb(huluoboHSV);%转换为RGB彩图,彩图中已经滤去了其余水果,只剩下胡萝卜
    subplot(2,2,4),imshow(huluobomatrix);
    
    
    
    
    % --- 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)
    global I Area FilledLabel HSV MeanHue  Ecllipseratio Label num Premeter
    %计算各个图形单元的周长   用连接像素点或数边界像素点个数的方法   numPoints数组表示各个图形边界的像素个数(即用个数来表示周长)
     %num = max(max(Label));
    
        for i = 1 : num
            Premeter(i) = 0;
        end
    
        [row,col] = size(Label);
        for i = 1 : row
            for j = 1 : col
                if(Label(i,j) > 0)
                    Premeter(Label(i,j)) = Premeter(Label(i,j)) + 1;%计算标记后的各块图形边界中像素的个数的总数
                end
            end
        end
    
    %计算各个图形单元的面积
    FilledLabel=imfill(Label,'holes');  %填充打过标记的边界线中间围成的图形区域
    for i = 1 : num
        Area(i) = 0;
    end
    
    [row,col] = size(FilledLabel);
    for i = 1 : row
        for j = 1 : col
            if(FilledLabel(i,j) > 0)
                Area(FilledLabel(i,j)) = Area(FilledLabel(i,j)) + 1;%通过统计像素点个数的方式来求各形状的面积
            end
        end
    end
    
    

    三、运行结果

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    四、备注

    完整代码或者代写添加QQ 1564658423

    展开全文
  • 基于matlab GUI草莓识别 二、源代码 function varargout = untitled(varargin) % UNTITLED M-file for untitled.fig % UNTITLED, by itself, creates a new UNTITLED or raises the existing % singleton*. % % H = ...

    一、简介

    基于matlab GUI草莓识别

    二、源代码

    function varargout = untitled(varargin)
    % UNTITLED M-file for untitled.fig
    %      UNTITLED, by itself, creates a new UNTITLED or raises the existing
    %      singleton*.
    %
    %      H = UNTITLED returns the handle to a new UNTITLED or the handle to
    %      the existing singleton*.
    %
    %      UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in UNTITLED.M with the given input arguments.
    %
    %      UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before untitled_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to untitled_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 untitled
    
    % Last Modified by GUIDE v2.5 11-Jan-2013 13:05:10
    
    % Begin initialization code - DO NOT EDIT
    
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @untitled_OpeningFcn, ...
                       'gui_OutputFcn',  @untitled_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 untitled is made visible.
    function untitled_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 untitled (see VARARGIN)
    
    % Choose default command line output for untitled
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    
    % UIWAIT makes untitled wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = untitled_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 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)
    
    global im;
    global str;
    [filename,pathname]=uigetfile_new({'*.*'},'选择训练图片...');
    str=[pathname  filename];
    im=imread(str);
    axes(handles.axes1);
    imshow(im);
    
    
    
    % --- Executes on button press in pushbutton2.
    function pushbutton2_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    global im1;
    global str1;
    [filename,pathname]=uigetfile_new({'*.*'},'选择测试图片...');
    str1=[pathname  filename];
    im1=imread(str1);
    axes(handles.axes2);
    imshow(im1);
    
    
    % --- Executes on button press in pushbutton3.
    function pushbutton3_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton3 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    global im;
    global im1;
    global str1;
    se1 = strel('disk',5);
    se2 = strel('square',16);
    thresh1 = 0.2;
    thresh2 = 0.01;
    imtra = im2double(im);
    rt = imtra(:,:,1);
    gt = imtra(:,:,2);
    bt = imtra(:,:,3);
    idxr1 = find(rt>0);
    idxg1 = find(gt>0);
    idxb1 = find(bt>0);
    
    mr1 = mean(rt(idxr1));
    mg1 = mean(gt(idxg1));
    mb1 = mean(bt(idxb1));
    function  n = adjvar(im)
    [row,col] = size(im);
    x = ones(row+4,col+4);
    x = -x;
    x(3:row+2,3:col+2) = im;
    idx = find(x~=-1);
    y(:,1) = x(idx);
    y(:,2) = x(idx-1);
    y(:,3) = x(idx+1);
    y(:,4) = x(idx-row-4);
    y(:,5) = x(idx+row+4);
    y(:,6) = x(idx-row-5);
    y(:,7) = x(idx-row-3);
     
    v = var(y,0,2);
     
    n = imadjust(n);
    

    三、运行结果

    在这里插入图片描述

    四、备注

    完整代码或者代写添加QQ 1564658423

    展开全文
  • 基于matlab GUI 灰度、二值、腐蚀、直方图处理之水果识别 二、源代码 function varargout = the4th(varargin) %========filename:the4th.m============% %=========水果图像的模式识别==12120389==曹嘉=====% %===...

    一、简介

    基于matlab GUI 灰度、二值化、腐蚀、直方图处理之水果识别

    二、源代码

    function varargout = the4th(varargin)
    %========filename:the4th.m============%
    %=========水果图像的模式识别==12120389==曹嘉=====%
    %==========include files:the4th.m===================%
    %========================exam.m===================%
    %========================exam1.m==================%
    %========================do.m=====================%
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @the4th_OpeningFcn, ...
                       'gui_OutputFcn',  @the4th_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 the4th is made visible.
    function the4th_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 the4th (see VARARGIN)
    
    % Choose default command line output for the4th
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    
    % UIWAIT makes the4th wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
    clc
    clear
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = the4th_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 menu_1_Callback(hObject, eventdata, handles)
    % hObject    handle to menu_1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    global fea testimg mask;
    
    
    
    % --------------------------------------------------------------------
    function menu_2_Callback(hObject, eventdata, handles)
    % hObject    handle to menu_2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function menu_3_Callback(hObject, eventdata, handles)
    % hObject    handle to menu_3 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function menu_4_Callback(hObject, eventdata, handles)
    % hObject    handle to menu_4 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function menu_5_Callback(hObject, eventdata, handles)
    % hObject    handle to menu_5 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function menu_6_Callback(hObject, eventdata, handles)
    % hObject    handle to menu_6 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    % --- Executes during object creation, after setting all properties.
    
    
    % --------------------------------------------------------------------
    function menu_61_Callback(hObject, eventdata, handles)
    % hObject    handle to menu_61 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    clear
    % 读入样本图像
    img1 = imread('梨.jpg');
    bwpic = RGB2bw(img1);
    samfea(1,:) = get_features(img1, bwpic);
    img2 = imread('青椒.jpg');
    bwpic = RGB2bw(img2);
    samfea(2,:) = get_features(img2, bwpic);
    img3 = imread('西红柿.jpg');
    bwpic = RGB2bw(img3);
    samfea(3,:) = get_features(img3, bwpic);
    img4 = imread('香蕉.jpg');
    bwpic = RGB2bw(img4);
    samfea(4,:) = get_features(img4, bwpic);
    
    %读入测试图像
    testimg = imread('test.jpg');
    % 测试图像二值化
    bwpic = RGB2bw(testimg);
    %figure, imshow(testimg)
    
    % 分离各个目标
    L = bwlabel(bwpic,4);
    mask = zeros(size(bwpic,1),size(bwpic,2), 4);
    
    for i=1:4
    	Tmask = zeros(size(bwpic,1),size(bwpic,2));
        [r, c] = find(L==i);
        for j=1:length(r)
            Tmask(r(j), c(j)) = 1;
        end
    	%figure, image(Tmask)
    	mask(:,:,i) = Tmask;
    end
    
    % 特征提取
    for i=1:4
        testfea(i,:) = get_features(testimg, mask(:,:,i));
    end
    name = {'梨', '青椒', '西红柿', '香蕉'};
    
    % 识别
    index = recognition(testfea, samfea);
    
    % 显示结果
    %figure
    imshow(testimg)
    
    hold on
    for i=1:4
        R = regionprops(mask(:,:,i),'boundingbox' );
        Rect = R.BoundingBox;
        if i==3 
        text(Rect(1)+Rect(3),Rect(2), name(index(i)-1))
        else
        text(Rect(1)+Rect(3),Rect(2), name(index(i)))
        end
    end
    
    
    

    三、运行结果

    在这里插入图片描述

    四、备注

    完整代码或者代写添加QQ 1564658423

    展开全文
  • 基于matlab GUI 二维码生成与识别 二、源代码 function varargout = QRcode(varargin) % QRCODE MATLAB code for QRcode.fig % QRCODE, by itself, creates a new QRCODE or raises the existing % singleton*. % % ...
  • QR码属于矩阵式二维码中的一个种类,由DENSO(日本电装)公司开发,由JIS和ISO将其标准。QR码的样子其实在很多场合已经能够被看到了。 (1)位置探测图形、位置探测图形分隔符:用于对二维码的定位,对每个QR码来说...
  • 本课题为基于matlab的人数统计系统。近年来,很多行业对人流信息有极大的需求,如汽车公交站,地铁站台,商场出入口等。通过人数统计系统可以方便、可靠、实时地对各种场所的人流进行统计,而不对公众造成任何影响。...
  • 数字图像处理——Matlab GUI灰度变换函数简介Matlab具有强大的函数运算功能,利用这一点可以进行像素级的计算,也就是图像处理。这款软件基于Matlab平台,用户可以在软件界面中打开需要修改的图片,选择想要变换的...
  • 基于matlab GUI 灰度、二值、腐蚀、直方图处理之水果识别 二、源代码 function varargout = untitled(varargin) % UNTITLED MATLAB code for untitled.fig % UNTITLED, by itself, creates a new UNTITLED or ...
  • 基于matlab GUI草莓识别 二、源代码 function varargout = untitled(varargin) % UNTITLED M-file for untitled.fig % UNTITLED, by itself, creates a new UNTITLED or raises the existing % singleton*. % % H = ...
  • 基于matlab GUI 灰度、二值、腐蚀、直方图处理之水果识别 二、源代码 function varargout = the4th(varargin) %========filename:the4th.m============% %=========水果图像的模式识别==12120389==曹嘉=====% %===...
  • 基于matlab GUI 二维码生成与识别 二、源代码 function varargout = QRcode(varargin) % QRCODE MATLAB code for QRcode.fig % QRCODE, by itself, creates a new QRCODE or raises the existing % singleton*. % % ...
  • 该源码为MATLAB图像处理GUI的源代码,包含图像灰度转化,二值、边缘检测、以及图像增强、直方图均衡等功能。
  • 该博客基于matalb GUI界面的水果分级系统,该系统适用范围以圆形水果为准,比如橘子,龙眼等,以统计水果的直径、色泽等多参数进行评价。该系统带一个GUI界面,通过设置直径与色泽,测试水果的这些参数,从而得出该...
  • Matlab图像读入灰度化存储边缘检测-simple application.rar simple application.rar file:///C:/Documents and Settings/Administrator/桌面file:///C:/Documents and Settings/Administrator...
  • 建立基于MatlabGUI界面,通过菜单选择来实现; 图像处理基本功能,包括:“打开”,“保存”,“退出”功能; 图像点运算,包括:灰度直方图,灰度线性变换,阈值变换和直方图均衡; 图像几何运算,包括:平移,...
  • 1、灰度化:提取jpg图像各个像素点的R、G、B三个类型的值,再对其进行加权平均。最后得到一个通道红绿蓝三个类型的加权平均。公式为:ima=0.299*ima_red+0.587*ima_green+0.114*ima_blue。2、二值化:二值化是在图像...
  • 基于matlab GUI数字图像处理:灰度化、二值化、中值滤波、低通滤波、均值滤波、高斯滤波、直方图、腐蚀、canny、sobel。 二、源代码 function varargout = image_processing(varargin) % IMAGE_PROCESSING MATLAB ...
  • 支持图像的打开,保存、添加各类噪声、图片的旋转,图像类型的转换,图像形态学处理、直方图均衡以及灰度直方图的显示。
  • 自己做的一个简易数字图像处理系统课程设计,实现了图像的基本变换(如灰度化、二值化)、几何形状变换、图像增强、图像分割和形态学处理功能,功能完善,代码详细。
  • 主要有光学指纹采集技术、电容式传感器指纹采集、温度传感指纹获取技术、超声波指纹采集技术、电磁波指纹采集技术,获得图像后进行预处理加工,要实现图像的灰度变换、分割、均衡、增强、 细化等预处理步骤。...
  • DATE: 2020.10.18 文章目录1、前言2、数字图像处理平台展示2.1、初始界面2.2、示例1...灰度处理:反色、直方图均衡、阈值 图像增强:加噪声、平滑滤波(均值、邻域平均、中值、巴特沃斯低通)、锐化(梯度、拉
  • 系统的图像预处理模块是将图像经过图像灰度化、图像增强、边缘提取、二值化等操作,转换成便于车牌定位的二值化图像;利用车牌的边缘、形状等特征,再结合Roberts 算子边缘检测、数字图像、形态学等技术对车牌进行...
  • 首先采用MATLAB的imread.m函数读取手写体数字图像,因为字母图像还没有达到提取特征和输入识别的要求,本文中采用自定义的归一化算法进行图像预处理,将灰度化、二值话图像归一化处理,再用逐像素特征提取法提取数字特征...
  • 基于matlab GUI数字图像处理平台:8大功能 1 文件操作:读取显示、保存图像、退出; 2 图像编辑:图像缩放、图像滤波、图像剪裁、格式转换、纹理映射; 3 图像分析:像素选择、强度描述图、图像轮廓图、绘制直方图; ...
  • 里面包含了直方图、直方图均衡灰度变换、高斯噪声、椒盐噪声、去噪、二值、中值滤波、自适应滤波、五种边缘检测算子(Canny、Roberts、Sobel、LoG、Prewitt)的源代码(包含.m文件),可以直接运行。
  • 实例一: 将一张彩色图像转化为灰度图像(彩色图像灰度化)。 第一步:GUIDE画界面。创建一个空的GUI界面,将需要的控件从左侧拖至右侧界面,并改变其属性。 第二步:编辑代码。在完成第一步后,点击“运行图窗”...
  • 里面有图片的存储和读取、简单的计算器和电子琴、图像的几何变换、图像的灰度变换、图像的滤波、边缘检测、二值、直方图均衡、噪声、函数画图、音乐播放器、图像的彩色通道分离和组合等等。源代码可以直接运行...

空空如也

空空如也

1 2 3 4 5 ... 8
收藏数 160
精华内容 64
关键字:

matlabgui灰度化

matlab 订阅