Matlab批量图像进行边缘检测

综合编程 2017-05-13

近日在做图像的边缘检测,需要加载很多幅图像,一个一个的处理太麻烦了,所以就用了一下循环,批量加载图像,轻松搞定。关于边缘检测的相关理论知识 blog.sina.com.cn/s/blog_9f4bc8e301016h7r.html
,今天就不多说了,下面就直接上代码了。

clc;

clear;

GrayPath='F:carclearimgOriginalOriginalGray';%获取当前路径下的所有灰度图像

EdgePath='F:carclearimgOriginalOriginalLogEdge';%保存的路径

ImgsPathList=dir(strcat(GrayPath,'*.JPG'));%获取所有jpg格式的图像

ImgsNum=length(ImgsPathList);%记录图像的数量

if ImgsNum>0

for j=1:ImgsNum

ImgsName=ImgsPathList(j).name;%读取图像名

Img=imread(strcat(GrayPath,ImgsName));%获取图像矩阵

% EdgeDeal = edge(Img,'log',0.04,1);

% EdgeDeal = edge(Img,'canny',0.2); %使用canny方法,业界最优秀

EdgeDeal = edge(Img,'log',0.01); %使用log方法

% figure;

% imshow(EdgeDeal);

title(ImgsName);

imwrite(EdgeDeal,strcat(EdgePath,ImgsName));%保存图像

end

end

您可能感兴趣的

3 open source alternatives to MATLAB Editor's note: This article was originally published in June 2016, and has been updated to provide some additional options which you may wish to consi...
Using MATLAB for hardware-in-the-loop prototyping ... MATLAB© is a programming language and environment designed for scientific computing. It is one of the best languages for developing robot con...
MathWorks Adds New Predictive Maintenance Product ... Introduces new toolbox for designing and testing condition monitoring and predictive maintenance algorithms NATICK, Mass.–(BUSINESS WIRE)–Math...
Changing a name and assigning a matrix in matlab Changing file names and copying to a different directory I have some files say about 1000 numbers.. Wanted to rename those files...
linux下用vim写matlab程序 使用matlab自带的编辑来写脚本感觉并不美妙,无法享受来自vim操作带来的便利,然而单纯使用vim来编辑,与matlab的交互性并不好,需要进行一定量的配置。所幸linux的工具众多,通过工具的的组合,也得与matlab的交互有了一定量的改善。 一、vim插件推荐 为...
简书

责编内容来自:简书 (本文源链)

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。