精华内容
下载资源
问答
  • matlabgui灰度变化

    2021-04-19 05:13:24
    课程设计报告册? 课程名称: 课题名称: ...《数字视音频技术》 课程设计报告 题目:基于 MATLAB GUI 的数字图像处...学号: 20994055003 数字图像处理论文 二〇 一二年十 月 基于灰度变换的图像增强及 Matlab 实现 摘...

    课程设计报告册? 课程名称: 课题名称: 专业班级: 姓名: MATLAB 课程设计 灰度变换增强 Bob Wang 学 号: 信息楼 220 15164 课程设计主要场所: 时间: ......

    《数字视音频技术》 课程设计报告 题目:基于 MATLAB GUI 的数字图像处...

    学号: 20994055003 数字图像处理论文 二〇 一二年十 月 基于灰度变换的图像增强及 Matlab 实现 摘要: 图像增强不仅可以用于提高图像的视觉外观, 而且还是图像边缘......

    2 应用 matlab 工具箱进行图像分析处理应用 matlab 的 Gui 文件对图片进行灰度处理,亮度处理,放大处理,翻转 处理,噪声处理,图像二值化,图像直方图、频谱图,滤波器......

    Key words: MATLAB, digital image processing,GUI , image enhancement,2-numeric image 第3页 一、数字图像处理概述 1.1 数字图像处理的意义 数字图像处理(......

    《基础强化训练》设计报告题 目: 二维灰度图象的统计分析及变换处理 专业班级: ...

    《数字视音频技术》 课程设计报告 题目:基于 MATLAB GUI 的数字图像处...

    基于MATLAB GUI 的数字图像处理系统小悠中文摘要 本文以 MATLAB 软件的图形用户界面(GUI)开发环境和图像处理工具箱为平台设计了数字图像增强处理系统,可实现灰度变换、......

    基于MATLABGUI 的数 字图像处理 This model paper was revised by the Standardization Office on December 10, 2020 数字图像处理课程论文 基于 matlab GUI 的彩色......

    《数字视音频技术》 课程设计报告 题目:基于 MATLAB GUI 的数字图像处...

    了解灰度变换增强和空域滤波增强的 Matlab 实现方法 2. 掌握直方图灰度变换方法 3. 掌握噪声模拟和图像滤波函数的使用方法 4..掌握平滑处理的算法和用途, 学习使用......

    《数字视音频技术》 课程设计报告题 目:基于 MATLAB GUI 的数字图像处...

    图像灰度转换与复原的matlab实现_理学_高等教育_教育专区。在RGB模型中,如果R=G=B时,则彩色表示一种灰度颜色,其中R=G=B的值叫灰度值,因此,灰度图像每个像素只......

    MATLAB与GUI图像的处理_其它_工作范文_实用文档。实用标准文案《 MATLAB 实践 》 课程设计 学生姓名: 学号: 专业班级: 指导教师: ### ### ### ### 精彩文......

    xx 学院本科生毕业设计(论文)任务书 2014 年 12 月 15 日至 2015 年 5 月 16 日 题 目: 基于 MATLAB GUI 的数字图象处理 教学演示平台设计 姓学系专年......

    图像灰度变化程序_数学_自然科学_专业资料。*** 实践教学 *** 兰州理工大...

    MATLAB 课程设计 GUI 图像处理文档编制序号:[KKIDT-LLE082...

    Matlab二维灰度图象分析及变换处理要点_其它_职业教育_教育专区。《基础强化训练》设计报告 题 目: 二维灰度图象的统计分析及变换处理 专业班级: 学生姓名: 指导......

    Matlab 二维灰度图象灰度化和分辨率的降低方法我是选用比较笨的方法先把先把彩图转化为灰度图然后再对灰度图 进行分辨率降低! 原图 1.1 灰白图 1.2 20*20 ......

    2 / 52 1 、设计目的:综合运用 MATLAB 工具箱实现图像处理的 GUI 程序设计, 利用 设计目的: MATLAB 图像处理工具箱,设计和实现自己的 Photoshop 。 2、题目......

    展开全文
  • MATLAB-图像灰度化处理

    2012-04-26 00:48:53
    M文件,可以在MATLAB平台上实现彩色图像的灰度化处理,有比对。
  • 数字图像处理——Matlab GUI灰度变换函数简介Matlab具有强大的函数运算功能,利用这一点可以进行像素级的计算,也就是图像处理。这款软件基于Matlab平台,用户可以在软件界面中打开需要修改的图片,选择想要变换的...

    数字图像处理——Matlab GUI与灰度变换函数

    简介

    Matlab具有强大的函数运算功能,利用这一点可以进行像素级的计算,也就是图像处理。这款软件基于Matlab平台,用户可以在软件界面中打开需要修改的图片,选择想要变换的效果,通过拖动滑动条可以动态显示修改后的图片效果。

    涉及到的图像处理包括以下三种灰度变换:

    • 二值化

    • 伽马变换

    • 对数变换

    使用方法

    不允许修改空图片,必须打开一张图片后才能获得修改图片的权限。

    打开文件后,面板上显示两张图片,左边的是原图,右边的是原图副本,可以动态显示修改效果。如图:
    这里写图片描述

    其中PhotoProcess包含三个菜单项,分别是

    • BinaryImage:图像二值化处理
    • Gamma Trans:伽马变换
    • Log Trans:对数变换

    下面分别对这三种功能进行演示:

    图像二值化

    这里写图片描述

    其中在子窗口中出现的拖动条可以动态调整二值化阀值(Threshold),这里取值0到1,从而显示出不一样的效果。

    *伽马变换*

    这里写图片描述
    类似二值化功能,这里也有一个拖动条,可以动态调整γ值,我们知道伽马变换的表达式:

    s=crγ

    其中c取1,不再接受变化。

    **对数变换

    这里写图片描述

    对数变换公式:

    s=clogv+1(1+vr)

    保存

    退出的时候如果还未保存将提示是否需要保存。 可选格式为bmp和jpg格式。如图为修改后的图片
    这里写图片描述

    参考资料

    [数字图像处理]灰度变换——反转,对数变换,伽马变换,灰度拉伸,灰度切割,位图切割

    《一个实例搞定matlab界面编程》 https://wenku.baidu.com/view/fdf6ad6925c52cc58bd6be8e.html

    附录:Matlab代码

    DIP.m

    function varargout = DIP(varargin)
    % DIP MATLAB code for DIP.fig
    %      DIP, by itself, creates a new DIP or raises the existing
    %      singleton*.
    %
    %      H = DIP returns the handle to a new DIP or the handle to
    %      the existing singleton*.
    %
    %      DIP('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in DIP.M with the given input arguments.
    %
    %      DIP('Property','Value',...) creates a new DIP or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before DIP_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to DIP_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 DIP
    
    % Last Modified by GUIDE v2.5 10-Apr-2017 16:55:51
    
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @DIP_OpeningFcn, ...
                       'gui_OutputFcn',  @DIP_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 DIP is made visible.
    function DIP_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 DIP (see VARARGIN)
    
    % Choose default command line output for DIP
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    
    % UIWAIT makes DIP wait for user response (see UIRESUME)
    % uiwait(handles.figure_DIP);
    setappdata(handles.figure_DIP,'img_src',0);
    set(handles.photoprocess,'Enable','off');
    setappdata(handles.figure_DIP,'bSave',false);
    setappdata(handles.figure_DIP,'bChanged',false);
    setappdata(handles.figure_DIP,'fstSave',true);
    setappdata(handles.figure_DIP,'fstPath',0);
    set(handles.toolSave,'Enable','off');
    set(handles.save,'Enable','off');
    set(handles.axes1,'visible','off');
    set(handles.axes2,'visible','off');
    % --- Outputs from this function are returned to the command line.
    function varargout = DIP_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 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 photoprocess_Callback(hObject, eventdata, handles)
    % hObject    handle to photoprocess (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function Untitled_8_Callback(hObject, eventdata, handles)
    % hObject    handle to Untitled_8 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function help_Callback(hObject, eventdata, handles)
    % hObject    handle to help (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function toBinary_Callback(hObject, eventdata, handles)
    % hObject    handle to toBinary (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);
    %img_src = getappdata(handles.figure_DIP,'img_src');
    %imshow(img_src);
    h = toBW;
    setappdata(handles.figure_DIP,'bChanged',true);
    set(handles.toolSave,'Enable','on');
    set(handles.save,'Enable','on');
    set(handles.axes2,'visible','on');
    % --------------------------------------------------------------------
    function gammatrans_Callback(hObject, eventdata, handles)
    % hObject    handle to gammatrans (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    h = toGamma;
    setappdata(handles.figure_DIP,'bChanged',true);
    set(handles.toolSave,'Enable','on');
    set(handles.save,'Enable','on');
    set(handles.axes2,'visible','on');
    
    % --------------------------------------------------------------------
    function contrast_Callback(~, eventdata, handles)
    % hObject    handle to contrast (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function brightness_Callback(hObject, eventdata, handles)
    % hObject    handle to brightness (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --------------------------------------------------------------------
    function open_Callback(hObject, eventdata, handles)
    % hObject    handle to open (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({'*.bmp;*.jpg;*.png;*.jpeg', 'Image Files (*.bmp, *.jpg, *.png,*.jpeg)'; '*.*', 'All Files (*.*)'}, 'Pick an image');
    if isequal(filename,0) || isequal(pathname,0),
        return;
    end
    axes(handles.axes1);%用axes命令设定当前操作的坐标轴是axes1
    fpath=[pathname filename];%将文件名和目录名组合成一个完整的路径
    img_src = imread(fpath);
    imshow(img_src);
    axes(handles.axes2);
    imshow(img_src);
    setappdata(handles.figure_DIP,'img_src',img_src);
    set(handles.photoprocess,'Enable','on');
    set(handles.axes1,'visible','on');
    % --------------------------------------------------------------------
    function save_Callback(hObject, eventdata, handles)
    % hObject    handle to save (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    fstSave=getappdata(handles.figure_DIP,'fstSave');
    if(fstSave==true)
        [filename, pathname] = uiputfile({'*.bmp','BMP files';'*.jpg;','JPG files'}, 'Pick an Image');
        if isequal(filename,0) || isequal(pathname,0)
            return;%如果点了“取消”
        else
            fpath=fullfile(pathname, filename);%获得全路径的另一种方法
        end    
        img_dst=getimage(handles.axes2);
        imwrite(img_dst,fpath);%保存图片
        setappdata(handles.figure_DIP,'fstPath',fpath);
        setappdata(handles.figure_DIP,'bSave',true);
        setappdata(handles.figure_DIP,'fstSave',false);
    else
        img_dst=getimage(handles.axes2);
        fpath=getappdata(handles.figure_DIP,'fstPath');
        imwrite(img_dst,fpath);
    end
    % --------------------------------------------------------------------
    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)
    bChanged=getappdata(handles.figure_DIP,'bChanged');%获得是否更改
    bSave=getappdata(handles.figure_DIP,'bSave');%获得是否保存
    if bChanged==true && bSave==false,%更改了,而没保存时
        btnName=questdlg('Not Saved Yet','Warning','save','leave','save');%用提问对话框
        switch btnName,
          case 'save', %执行axes_dst_menu_save_Callback的功能
            feval(@save_Callback,handles.save,eventdata,handles);
          case 'leave',%什么也不做
        end
    end
    h=findobj('Tag','figure_toBW');%查找是否打开设置图像二值化参数窗口
    hh=findobj('Tag','figure_toLogTrans');
    hhh=findobj('Tag','figure_toGamma');
    if ~isempty(h),%找到的话,则关闭
      close(h);
      close(hh);
      close(hhh);
    end
    close(findobj('Tag','figure_DIP'));%关闭主窗口
    
    
    % --------------------------------------------------------------------
    function toolOpen_ClickedCallback(hObject, eventdata, handles)
    % hObject    handle to toolOpen (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    feval(@open_Callback,handles.open,eventdata,handles);
    
    
    % --------------------------------------------------------------------
    function toolSave_ClickedCallback(hObject, eventdata, handles)
    % hObject    handle to toolSave (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    feval(@save_Callback,handles.save,eventdata,handles);
    
    
    % --- 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
    set(hObject,'xTick',[]);
    set(hObject,'ytick',[]);
    set(hObject,'box','on');
    % 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
    set(hObject,'xTick',[]);
    set(hObject,'ytick',[]);
    set(hObject,'box','on');
    % Hint: place code in OpeningFcn to populate axes2
    
    
    % --------------------------------------------------------------------
    function logtrans_Callback(hObject, eventdata, handles)
    % hObject    handle to logtrans (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);
    %img_src = getappdata(handles.figure_DIP,'img_src');
    %imshow(img_src);
    h = toLogTrans;
    setappdata(handles.figure_DIP,'bChanged',true);
    set(handles.toolSave,'Enable','on');
    set(handles.save,'Enable','on');
    set(handles.axes2,'visible','on');
    

    toBW.m

    function varargout = toBW(varargin)
    % TOBW MATLAB code for toBW.fig
    %      TOBW, by itself, creates a new TOBW or raises the existing
    %      singleton*.
    %
    %      H = TOBW returns the handle to a new TOBW or the handle to
    %      the existing singleton*.
    %
    %      TOBW('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in TOBW.M with the given input arguments.
    %
    %      TOBW('Property','Value',...) creates a new TOBW or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before toBW_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to toBW_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 toBW
    
    % Last Modified by GUIDE v2.5 10-Apr-2017 00:49:18
    
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @toBW_OpeningFcn, ...
                       'gui_OutputFcn',  @toBW_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 toBW is made visible.
    function toBW_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 toBW (see VARARGIN)
    
    % Choose default command line output for toBW
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    %找到原始界面的句柄
    HH = findobj('Tag','figure_DIP');
    DIP = guihandles(HH);
    setappdata(handles.figure_toBW,'DIP',DIP)
    % UIWAIT makes toBW wait for user response (see UIRESUME)
    % uiwait(handles.figure_toBW);
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = toBW_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 slider movement.
    function slider1_Callback(hObject, eventdata, handles)
    % hObject    handle to slider1 (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
    val = get(hObject,'Value');
    set(handles.text_bw,'String',num2str(val));
    DIP = getappdata(handles.figure_toBW,'DIP');
    axes(DIP.axes2);
    img_src = getappdata(DIP.figure_DIP,'img_src');
    bw = im2bw(img_src,val);
    imshow(bw);
    
    
    % --- Executes during object creation, after setting all properties.
    function slider1_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to slider1 (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.
    if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor',[.9 .9 .9]);
    end
    

    LogTrans.m

    function   [g] = LogTrans(f,c,v)
    %此处显示详细说明
        h = mat2gray(f,[0,255]);
        g = c*log2(1+v*h)/log2(v+1);
    end
    

    toLogTrans.m

    function varargout = toLogTrans(varargin)
    % TOLOGTRANS MATLAB code for toLogTrans.fig
    %      TOLOGTRANS, by itself, creates a new TOLOGTRANS or raises the existing
    %      singleton*.
    %
    %      H = TOLOGTRANS returns the handle to a new TOLOGTRANS or the handle to
    %      the existing singleton*.
    %
    %      TOLOGTRANS('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in TOLOGTRANS.M with the given input arguments.
    %
    %      TOLOGTRANS('Property','Value',...) creates a new TOLOGTRANS or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before toLogTrans_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to toLogTrans_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 toLogTrans
    
    % Last Modified by GUIDE v2.5 10-Apr-2017 16:41:28
    
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @toLogTrans_OpeningFcn, ...
                       'gui_OutputFcn',  @toLogTrans_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 toLogTrans is made visible.
    function toLogTrans_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 toLogTrans (see VARARGIN)
    
    % Choose default command line output for toLogTrans
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    %找到原始界面的句柄
    HH = findobj('Tag','figure_DIP');
    DIP = guihandles(HH);
    setappdata(handles.figure_toLogTrans,'DIP',DIP)
    setappdata(handles.figure_toLogTrans,'val_C',0);
    setappdata(handles.figure_toLogTrans,'val_V',0);
    % UIWAIT makes toLogTrans wait for user response (see UIRESUME)
    % uiwait(handles.figure_toLogTrans);
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = toLogTrans_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 slider movement.
    function slider1_Callback(hObject, eventdata, handles)
    % hObject    handle to slider1 (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
    val_C = get(hObject,'Value');
    set(handles.text2,'String',num2str(val_C));
    setappdata(handles.figure_toLogTrans,'val_C',val_C);
    val_V = getappdata(handles.figure_toLogTrans,'val_V');
    DIP = getappdata(handles.figure_toLogTrans,'DIP');
    axes(DIP.axes2);
    img_src = getappdata(DIP.figure_DIP,'img_src');
    bw = LogTrans(img_src,val_C,val_V);
    imshow(bw);
    
    % --- Executes during object creation, after setting all properties.
    function slider1_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to slider1 (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.
    if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor',[.9 .9 .9]);
    end
    
    
    % --- Executes on slider movement.
    function slider2_Callback(hObject, eventdata, handles)
    % hObject    handle to slider2 (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
    val_V = get(hObject,'Value');
    set(handles.text4,'String',num2str(val_V));
    setappdata(handles.figure_toLogTrans,'val_V',val_V);
    val_C = getappdata(handles.figure_toLogTrans,'val_C');
    DIP = getappdata(handles.figure_toLogTrans,'DIP');
    axes(DIP.axes2);
    %img_src = getimage(DIP.axes2);
    img_src = getappdata(DIP.figure_DIP,'img_src');
    %bw = val_C*log2(1+val_V*img_src)/log2(val_V+1);
    bw = LogTrans(img_src,val_C,val_V);
    imshow(bw);
    % --- Executes during object creation, after setting all properties.
    function slider2_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to slider2 (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.
    if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor',[.9 .9 .9]);
    end
    

    toGamma.m

    function varargout = toGamma(varargin)
    % TOGAMMA MATLAB code for toGamma.fig
    %      TOGAMMA, by itself, creates a new TOGAMMA or raises the existing
    %      singleton*.
    %
    %      H = TOGAMMA returns the handle to a new TOGAMMA or the handle to
    %      the existing singleton*.
    %
    %      TOGAMMA('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in TOGAMMA.M with the given input arguments.
    %
    %      TOGAMMA('Property','Value',...) creates a new TOGAMMA or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before toGamma_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to toGamma_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 toGamma
    
    % Last Modified by GUIDE v2.5 10-Apr-2017 21:32:21
    
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @toGamma_OpeningFcn, ...
                       'gui_OutputFcn',  @toGamma_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 toGamma is made visible.
    function toGamma_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 toGamma (see VARARGIN)
    
    % Choose default command line output for toGamma
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    %找到原始界面的句柄
    HH = findobj('Tag','figure_DIP');
    DIP = guihandles(HH);
    setappdata(handles.figure_toGamma,'DIP',DIP)
    % UIWAIT makes toGamma wait for user response (see UIRESUME)
    % uiwait(handles.figure_toGamma);
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = toGamma_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 slider movement.
    function slider2_Callback(hObject, eventdata, handles)
    % hObject    handle to slider2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    val = get(hObject,'Value');
    set(handles.text2,'String',num2str(val));
    DIP = getappdata(handles.figure_toGamma,'DIP');
    axes(DIP.axes2);
    img_src = getappdata(DIP.figure_DIP,'img_src');
    c = 1;
    bw = GammaTrans(img_src,c,val);
    imshow(bw);
    
    % Hints: get(hObject,'Value') returns position of slider
    %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
    
    
    % --- Executes during object creation, after setting all properties.
    function slider2_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to slider2 (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.
    if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor',[.9 .9 .9]);
    end
    

    GammaTrans.m

    function  [g]=GammaTrans(f,c,gamma)
    %   此处显示详细说明
        h = mat2gray(f,[0,255]);
        g = c*(h.^gamma);
    end
    
    
    展开全文
  • 一个实例搞定MATLAB GUI界面设计,以图像二值处理为例。
  • 本课题为基于matlab的人数统计系统。近年来,很多行业对人流信息有极大的需求,如汽车公交站,地铁站台,商场出入口等。通过人数统计系统可以方便、可靠、实时地对各种场所的人流进行统计,而不对公众造成任何影响。...

    一、简介

    1 课题背景
    本课题为基于matlab的人数统计系统。近年来,很多行业对人流信息有极大的需求,如汽车公交站,地铁站台,商场出入口等。通过人数统计系统可以方便、可靠、实时地对各种场所的人流进行统计,而不对公众造成任何影响。结合其他图像分析技术,系统可以清楚快捷地掌握客流动态,提供数据支持,使决策者及时做出对策。利用图像处理来完成人数统计系统的主要优点就是图像信号非常直观,便于人为的理解。可以看出,图像的人数统计无论是在商业信息采集还是公共安全监控方面具有重要意义,图像的人数统计识别算法的研究无论在理论上还是在实际应用领域都有着诱人的发展前景。
    2 课题分析
    本文采用基于matlab GUI形态学人数统计,老师点名效率得到很大提升。
    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
    

    三、运行结果

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

    四、matlab版本及参考文献

    1 matlab版本
    2014a

    2 参考文献
    [1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
    [2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
    [3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
    [4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
    [5]孟逸凡,柳益君.基于PCA-SVM的人脸识别方法研究[J].科技视界. 2021,(07)
    [6]张娜,刘坤,韩美林,陈晨.一种基于PCA和LDA融合的人脸识别算法研究[J].电子测量技术. 2020,43(13)
    [7]陈艳.基于BP神经网络的人脸识别方法分析[J].信息与电脑(理论版). 2020,32(23)
    [8]戴骊融,陈万米,郭盛.基于肤色模型和SURF算法的人脸识别研究[J].工业控制计算机. 2014,27(02)

    展开全文
  • Matlab】实验二 GUI图像灰度变换

    千次阅读 2019-10-26 14:55:28
    3) 基于MATLAB平台实现在GUI内图像间的交互处理。 2.实验内容: 1) 编写MATLAB程序,完成图像的输入,并将该图像的直方图信息输出并保存。 2) 对上述图像进行直方图均衡处理,将得到的新图像与原图进行对比展示。...

    1.实验目的:

    1) 了解MATLAB软件平台的基本操作。

    2) 学会应用GUI输入输出图像,能提取图像的直方图信息,并能对图像进行直方图均衡。

    3) 基于MATLAB平台实现在GUI内图像间的交互处理。

    2.实验内容:

    1) 编写MATLAB程序,完成图像的输入,并将该图像的直方图信息输出并保存。

    2) 对上述图像进行直方图均衡处理,将得到的新图像与原图进行对比展示。

    3) 在1)读入的图像中任意选取一个大小150×150的子区域,输出并保存该子区域的灰度直方图,要求直方图的柱数(bin)为32。

    3.具体实验:

    界面设计如下:

                             

    具体代码如下:

    <1>读入原图像:

    % --- 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)
    im=imread('D:\cc_test.jpg');
    axes(handles.axes1);
    imshow(im)
    handles.im=im;
    guidata(hObject,handles)
    

    <2>直方图均衡处理:

    % --- 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)
    x = rgb2gray(handles.im);
    y = histeq(x);
    guidata(hObject,handles);
    axes(handles.axes5);
    imshow(y);
    

    <3>子区域图像显示:

    % --- 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)
    im2 = handles.im;
    ws = str2num(get(handles.edit1,'string'));
    pos = get(handles.axes1,'currentpoint');
    posx = floor(pos(1,2));
    posy = floor(pos(1,1));
    localimage=im2(posx-ws:posx+ws,posy-ws:posy+ws);
    axes(handles.axes3);
    imshow(localimage)
    handles.localimage = localimage;
    guidata(hObject,handles)
    

    <4>输出各图像的直方图:

    % --- Executes on button press in pushbutton5.
    function pushbutton5_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton5 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    x = rgb2gray(handles.im);
    y = histeq(x);
    im2 = handles.im;
    ws = str2num(get(handles.edit1,'string'));
    pos = get(handles.axes1,'currentpoint');
    posx = floor(pos(1,2));
    posy = floor(pos(1,1));
    localimage=im2(posx-ws:posx+ws,posy-ws:posy+ws);
    long = str2num(get(handles.edit2,'String'));
    axes(handles.axes2);
    imhist(x,long);
    axes(handles.axes6);
    imhist(y,long);
    axes(handles.axes4);
    imhist(localimage,long);
    

    实验结果:

                                

    实验总结:

    通过这次实验学会了使用imhist函数绘制直方图的方法,但是在实验过程中也遇到了一些问题,在“子区域显示”那块浪费了很多时间,一直报以下图片的那种错误:

    但是在机房实验时并未发生这种错误,个人初步认为是matlab版本的问题才会报错。在新版本的matlab上并未报错。

    展开全文
  • 基于matlab GUI灰度+缩放+存储 二、源代码 function varargout = GUI_TEST(varargin) % GUI_TEST MATLAB code for GUI_TEST.fig % GUI_TEST, by itself, creates a new GUI_TEST or raises the existing % singleton...
  • 该源码为MATLAB图像处理GUI的源代码,包含图像灰度转化,二值、边缘检测、以及图像增强、直方图均衡等功能。
  • GUI实现的功能:加载图片、灰度处理图片、0.5倍缩放图片、保存处理 版本为R2014a中文版本 二、源代码 function varargout = GUI_TEST(varargin) % GUI_TEST MATLAB code for GUI_TEST.fig % GUI_TEST, by itself, ...
  • 一、彩色、灰度、二值、索引图像 彩色图像:每个像素由R、G、B三个分量表示,每个通道取值范围0~255。数据类型一般为8位无符号整形unit8。(通常我们认为一个彩色图像是由三页组成的,分别是R、G、B,每一页都是一个...
  • 完整代码,可直接运行
  • MATLAB GUI设计 简单图像处理 灰度 | 缩放 | 存储 | GUI

    千次阅读 多人点赞 2020-03-20 13:48:05
    本简易图像处理GUI实现 加载图片、灰度处理图片、0.5倍缩放图片、保存处理后的图片功能;版本为R2018b 中文版本。
  • 基于MATLABGUI系统设计-aa.fig aa.fig aa.m bode.fig bode.m duo.fig ...
  • Matlab实现图像灰度化算法

    千次阅读 2020-03-16 21:12:56
    Matlab实现图像灰度化算法灰度化算法原理 灰度化算法原理 RGB应该都听说过,我们一般看到的彩色图像嘛,R、G、B分别对应了三原色:红色(red)、绿色(green)和蓝色(blue)。如果有玩过P图的,也许会知道,画板...
  • 利用matlabGUI功能编写的用于图像处理的代码。包括灰度化/对数指数变换/加噪声/平滑滤波/锐化/几何变换等。
  • 基于matlab GUI 灰度、二值、腐蚀、直方图处理之水果识别 二、源代码 function varargout = the4th(varargin) %========filename:the4th.m============% %=========水果图像的模式识别==12120389==曹嘉=====% %===...
  • 主要有光学指纹采集技术、电容式传感器指纹采集、温度传感指纹获取技术、超声波指纹采集技术、电磁波指纹采集技术,获得图像后进行预处理加工,要实现图像的灰度变换、分割、均衡、增强、 细化等预处理步骤。...
  • 支持图像的打开,保存、添加各类噪声、图片的旋转,图像类型的转换,图像形态学处理、直方图均衡以及灰度直方图的显示。
  • 首先采用MATLAB的imread.m函数读取手写体数字图像,因为字母图像还没有达到提取特征和输入识别的要求,本文中采用自定义的归一化算法进行图像预处理,将灰度化、二值话图像归一化处理,再用逐像素特征提取法提取数字特征...
  • 基于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 GUI 灰度、二值、腐蚀、直方图处理之水果识别 二、源代码 function varargout = untitled(varargin) % UNTITLED MATLAB code for untitled.fig % UNTITLED, by itself, creates a new UNTITLED or ...
  • MATLAB GUI程序设计epub

    2021-04-24 01:35:27
    MATLAB GUI程序设计 作者:王广,邢林芳MATLAB GUI程序设计 出版社:清华大学出版社MATLAB GUI程序设计 内容简介全书的编写基于当前版本的MATLAB环境,书中由浅入深地全面讲解了MATLABGUI设计方面应用的知识。...
  • Matlab图像读入灰度化存储边缘检测-simple application.rar simple application.rar file:///C:/Documents and Settings/Administrator/桌面file:///C:/Documents and Settings/Administrator...
  • 建立基于MatlabGUI界面,通过菜单选择来实现; 图像处理基本功能,包括:“打开”,“保存”,“退出”功能; 图像点运算,包括:灰度直方图,灰度线性变换,阈值变换和直方图均衡; 图像几何运算,包括:平移,...
  • 图片处理 rgb2gray :通过消除图像色调和饱和度信息同时保留亮度实现将将RGB图像或彩色图转换为灰度图像,即灰度化处理的功能 gdata = rgb2gray(data); graythresh :最大类间方差法是一种自适应的阈值确定的方法...
  • 127电子技术 1 引言 目前 B 超成像、计算机断层扫描成像(CT)、X 射线成像、磁共振成像(MRI)等医学领域获得的原始图像多为灰度图像,常用 8 位256 个灰度级或 16 位 65536 个灰度级表示,分辨率已经相当高,但是人眼...
  • 自己做的一个简易数字图像处理系统课程设计,实现了图像的基本变换(如灰度化、二值化)、几何形状变换、图像增强、图像分割和形态学处理功能,功能完善,代码详细。
  • 里面有图片的存储和读取、简单的计算器和电子琴、图像的几何变换、图像的灰度变换、图像的滤波、边缘检测、二值、直方图均衡、噪声、函数画图、音乐播放器、图像的彩色通道分离和组合等等。源代码可以直接运行...
  • 本文基于MATLAB图像用户界面(GUI)和图像处理工具箱设计实现了一款图像处理系统,该系统可实现图像的运算、变换、分割、改善、形态学处理、压缩编码等内容,并通过综合实例阐述了本系统在图像识别中的应用,使图像...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,337
精华内容 534
关键字:

matlabgui灰度化

matlab 订阅