一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【图像几何】基于matlab投影法测距【含Matlab源码 405期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、投影法简介

投影,在立体几何中我们学到过,是空间直线在某个方向上的投影,那么图像处理中也是这种投影思想。

最简单的投影:
水平方向投影,将图像数组进行列求和;
垂直方向投影,将图像数组进行行求和;
对于二值图像或明显特征的灰度图分割前景与背景,经常用到投影法。

三、部分源代码

function varargout = jiemian(varargin)
% JIEMIAN M-file for jiemian.fig
%      JIEMIAN, by itself, creates a new JIEMIAN or raises the existing
%      singleton*.
%
%      H = JIEMIAN returns the handle to a new JIEMIAN or the handle to
%      the existing singleton*.
%
%      JIEMIAN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in JIEMIAN.M with the given input arguments.
%
%      JIEMIAN('Property','Value',...) creates a new JIEMIAN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before jiemian_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to jiemian_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 jiemian% Last Modified by GUIDE v2.5 03-Nov-2012 02:26:28% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @jiemian_OpeningFcn, ...'gui_OutputFcn',  @jiemian_OutputFcn, ...'gui_LayoutFcn',  [] , ...'gui_Callback',   []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end
% End initialization code - DO NOT EDIT% --- Executes just before jiemian is made visible.
function jiemian_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 jiemian (see VARARGIN)% Choose default command line output for jiemianhandles.output = hObject;% Update handles structureguidata(hObject, handles);clc;axes(handles.axes2);imshow(imread('logo.jpg'));global file;global I;global vid;global P;P=0;global n;n=0;set(handles.edit1,'String','10');set(handles.edit2,'String','0');set(handles.edit3,'String','0');set(handles.edit4,'String','0');set(handles.edit5,'String','0');% UIWAIT makes jiemian wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = jiemian_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 structurevarargout{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)
set(handles.edit6,'String','...');
hold off;
global n;n=0;
set(handles.radiobutton1,'value',1);
set(handles.edit1,'String','10');
set(handles.edit3,'String','0');
set(handles.edit4,'String','0');
set(handles.edit5,'String','0');
global P;
if P==8global vid;axes(handles.axes1);I=getsnapshot(vid);imshow(I);set(handles.edit7,'String','“摄像头拍摄图像”');
else[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.tif';'*.*'},'打开图像...');if isequal(filename,0)|isequal(pathname,0)errordlg('图像文件未找到','File Error');elseglobal file;global I;P=1;file=[pathname,filename];I=imread(file);axes(handles.axes1);imshow(I);set(handles.edit7,'String','“元件的原始图像”');end
end
set(handles.edit6,'String','OK');% --- 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)
set(handles.edit6,'String','...');
hold off;
global file;
global I;
global P;
global n;n=0;
set(handles.radiobutton1,'value',1);
set(handles.edit3,'String','0');
set(handles.edit4,'String','0');
set(handles.edit5,'String','0');
if P==8axes(handles.axes1);cla reset;
else if P == 0errordlg('请先打开图像!','Warning...');elseP=1;I=imread(file);axes(handles.axes1);imshow(I);set(handles.edit7,'String','“元件的原始图像”');end
end
set(handles.edit6,'String','OK');% --- 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)
set(handles.edit6,'String','...');
global P;
if P == 0errordlg('请先打开图像!','Warning...');
else[filename,pathname]=uiputfile({'*.jpg';'*.bmp';'*.tif';'*.*'},'保存图片...','Undefined');if ~isequal(filename,0)str = [pathname filename];px=getframe(handles.axes1);cdata = getappdata(gcf,'Timg');imwrite(px.cdata,str);else errordlg('保存失败!','Warning...');end;
end
set(handles.edit6,'String','OK');% --- 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)
set(handles.edit6,'String','...');
global P;
P=0;
set(handles.edit3,'String','0');
set(handles.edit4,'String','0');
set(handles.edit5,'String','0');
axes(handles.axes1);
cla reset;
closepreview;
set(handles.edit7,'String','“请先打开图像”');
set(handles.edit6,'String','OK');% --- 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)
set(handles.edit6,'String','...');
global I;
global P;
switch Pcase 7,errordlg('图像已经完成二值化,请直接测距或复位!','Warning...');case 6,errordlg('图像已经增强对比度,请放弃该操作或复位!','Warning...');case 5,errordlg('已经截取目标,请放弃该操作或复位!','Warning...');case 4,errordlg('已经选取标定目标,请放弃该操作或复位!','Warning...');case 3,errordlg('图像已经完成几何校正,请放弃该操作或复位!','Warning...');case 2,errordlg('图像已经完成中值滤波,请放弃该操作或复位!','Warning...');case 1,P=2;I=rgb2gray(I);                                          %转化为灰度I=medfilt2(I,[3 3]);                                     %中值滤波axes(handles.axes1);imshow(I);set(handles.edit7,'String','“中值滤波后的元件图像”');case 0,errordlg('请先打开图像!','Warning...');
end

四、运行结果

五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]陈浩,方勇,朱大洲,王成,陈子龙.基于蚁群算法的玉米植株热红外图像边缘检测[J].农机化研究. 2015,37(06)

【图像几何】基于matlab投影法测距【含Matlab源码 405期】相关推荐

  1. 【Matlab验证码识别】遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别【含GUI源码 1694期】

    一.代码运行视频(哔哩哔哩) [Matlab验证码识别]遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别[含GUI源码 1694期] 二.matlab版本及参考文献 1 matlab ...

  2. 【Matlab图像融合】小波变换遥感图像融合【含GUI源码 744期】

    一.代码运行视频(哔哩哔哩) [Matlab图像融合]小波变换遥感图像融合[含GUI源码 744期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 包子阳,余 ...

  3. 【Matlab图像加密】正交拉丁方置乱算法图像加解密【含GUI源码 182期】

    一.代码运行视频(哔哩哔哩) [Matlab图像加密]正交拉丁方置乱算法图像加解密[含GUI源码 182期] 二.matlab版本及参考文献 一.代码运行视频(哔哩哔哩) [Matlab图像处理]自动 ...

  4. 【Matlab车牌识别】停车计费系统【含GUI源码 735期】

    一.代码运行视频(哔哩哔哩) [Matlab车牌识别]停车计费系统[含GUI源码 735期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 蔡利梅.MATLA ...

  5. 【Matlab生物电信号】生物电信号仿真【含GUI源码 684期】

    一.代码运行视频(哔哩哔哩) [Matlab生物电信号]生物电信号仿真[含GUI源码 684期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]董兵,超于毅,李 ...

  6. 【Matlab语音分析】语音信号分析【含GUI源码 1718期】

    一.代码运行视频(哔哩哔哩) [Matlab语音分析]语音信号分析[含GUI源码 1718期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]韩纪庆,张磊,郑铁 ...

  7. 【Matlab人脸识别】BP神经网络人脸识别(含识别率)【含GUI源码 891期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]BP神经网络人脸识别(含识别率)[含GUI源码 891期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] ...

  8. 【Matlab人脸识别】形态学教室人数统计(带面板)【含GUI源码 1703期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]形态学教室人数统计(带面板)[含GUI源码 1703期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟 ...

  9. 【Matlab人脸识别】人脸实时检测与跟踪【含GUI源码 673期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]人脸实时检测与跟踪[含GUI源码 673期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟逸凡,柳益君 ...

  10. 【Matlab语音加密】语音信号加密解密(带面板)【含GUI源码 181期】

    一.代码运行视频(哔哩哔哩) [Matlab语音加密]语音信号加密解密(带面板)[含GUI源码 181期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]韩纪庆 ...

最新文章

  1. PCL深度图像(1)
  2. JSP装状态管理 session cookie
  3. OpenStack在keystone部分同步数据库报错Errno 13解决办法
  4. 转载:【opencv入门教程之六】创建Trackbar图片对比度、亮度值调整
  5. fastjson使用中遇到的
  6. [蓝桥杯][2015年第六届真题]机器人塔(DFS)
  7. mysql 快照能否恢复某个表_mysql全库备份恢复某个表
  8. 数据库 proc编程七
  9. 《飞鸽传书2007绿色版下载》总结报告
  10. 【Python】自动化升级所有pip安装的包
  11. 小记css的margin collapsing
  12. 一些常用算法 练手的的代码
  13. Vue.2.0.5-Class 与 Style 绑定
  14. 一、struts入门
  15. 有限元分析基础操作(ANSYS)
  16. 2020年中国激光切割运控系统需求现状及竞争格局分析,高功率快速增长「图」
  17. AI微信小程序源码下载人脸照片AI转换动漫照片全新源码安装简单无需服务器域名
  18. Linux里面输入错误无法使用Backspace键
  19. if-else语句练习
  20. JAVA代码托管平台_推荐几个常用的代码托管平台

热门文章

  1. 网站优化如何创作优质的内容?
  2. python中if __name__ == __main__:用法解析
  3. osgEarth文档翻译1
  4. vs2010无法添加dll引用
  5. linux ubuntu 11.10 下的android开发环境的搭建!
  6. codesmith执行时提示“调用的目标发生了异常”的处理过程经验。
  7. 拉里·佩奇 密歇根大学演讲
  8. 190529每日一句,放胆去梦想,努力去奋斗
  9. tinyxml读xml文件
  10. Atitit api design Usability simple 易用性之简单化设计 目录 1. 理论原则 2 1.1. 概念简单 2 1.2. 切换到了“write less, do more