使用matlab对裂缝进行检测

您所在的位置:网站首页 裂缝宽度检测实验报告 使用matlab对裂缝进行检测

使用matlab对裂缝进行检测

2023-12-26 09:48| 来源: 网络整理| 查看: 265

原始图片 

 这张图片不滤波处理的灰度图上有很多杂点

I=imread('G:\pictures\l2.jpg'); subplot(331);imshow(I); title('原始图像'); %增强图像 adjImg=imadjust(I,[0.10,0.60],[0,1]); subplot(332);imshow(adjImg); title('增强图'); %矫正不均匀亮度 se=strel('disk',15); imbImg=imbothat(adjImg,se); subplot(333);imshow(imbImg); title('底帽变换矫正不均匀亮度'); %滤波图像 H = fspecial('gaussian',6,6); filImg = imfilter(imbImg,H,'replicate'); subplot(334),imshow(filImg); title('滤波去噪'); %灰度化 % G =rgb2gray(filImg); % subplot(335),imshow(G); % title('灰度化图像'); %灰度直方图 % subplot(336),imhist(G); % title('灰度直方图'); %模糊化 K=fspecial('disk',10); blurred = imfilter(filImg,K,'replicate'); subplot(336),imshow(blurred); title('模糊图'); %二值化图像 bw=im2bw(G,150/255); subplot(337),imshow(bw); title('二值化图像'); %去除图像 bw2 = bwareaopen(im2uint8(bw),250);%将小于XX像素的单元去掉 subplot(338),imshow(bw2); title('去除图像'); %标记图像 [L1, num1] = bwlabel(bw2);%把每个连通区域贴上标签,L为贴标签之后的矩阵,num为标签个数 stats = regionprops(L1);%获取区域的某个属性(面积、最小包围矩形的坐标长宽等)的值 subplot(339),imshow(L1); title('标记图像'); hold on; for i = 1 : num1 tempBound = stats(i).BoundingBox; rectangle('position',tempBound,'edgecolor','b'); end

处理不同的裂缝要调整不同的参数,原始图是我在网上随便找的一张图片,如果要处理别的图片就要调了,不知道有没有什么好的方法来处理,一起学习学习

处理完的结果图  

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3