✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
提出一种基于MATLAB的道路裂缝识别方法,在对道路裂缝图像灰度化的基础上,利用最大类间方差法提取可能存在的道路裂缝,再对图像进行形态学操作,去除图像中的非裂缝区域,最后用凸包对裂缝区域进行标识,得到图像中实际存在的裂缝区域.在采集到的道路裂缝图像的实验结果表明,提出的方法可以准确地标注道路裂缝.
⛄ 部分代码
function out = imoverlay(in, mask, color)
%IMOVERLAY Create a mask-based image overlay.
% OUT = IMOVERLAY(IN, MASK, COLOR) takes an input image, IN, and a binary
% image, MASK, and produces an output image whose pixels in the MASK
% locations have the specified COLOR.
%
% IN should be a grayscale or an RGB image of class uint8, uint16, int16,
% logical, double, or single. If IN is double or single, it should be in
% the range [0, 1]. If it is not in that range, you might want to use
% mat2gray to scale it into that range.
%
% MASK should be a two-dimensional logical matrix.
%
% COLOR should be a 1-by-3 vector of values in the range [0, 1]. [0 0 0]
% is black, and [1 1 1] is white.
%
% OUT is a uint8 RGB image.
%
% Examples
% --------
% Overlay edge detection result in green over the original image.
%
% I = imread('cameraman.tif');
% bw = edge(I, 'canny');
% rgb = imoverlay(I, bw, [0 1 0]);
% imshow(rgb)
%
% Treating the output of peaks as an image, overlay the values greater than
% 7 in red. The output of peaks is not in the usual grayscale image range
% of [0, 1], so use mat2gray to scale it.
%
% I = peaks;
% mask = I > 7;
% rgb = imoverlay(mat2gray(I), mask, [1 0 0]);
% imshow(rgb, 'InitialMagnification', 'fit')
% Steven L. Eddins
% Copyright 2006-2012 The MathWorks, Inc.
% If the user doesn't specify the color, use white.
DEFAULT_COLOR = [1 1 1];
if nargin < 3
color = DEFAULT_COLOR;
end
% Force the 2nd input to be logical.
mask = (mask ~= 0);
% Make the uint8 the working data class. The output is also uint8.
in_uint8 = im2uint8(in);
color_uint8 = im2uint8(color);
% Initialize the red, green, and blue output channels.
if ismatrix(in_uint8)
% Input is grayscale. Initialize all output channels the same.
out_red = in_uint8;
out_green = in_uint8;
out_blue = in_uint8;
else
% Input is RGB truecolor.
out_red = in_uint8(:,:,1);
out_green = in_uint8(:,:,2);
out_blue = in_uint8(:,:,3);
end
% Replace output channel values in the mask locations with the appropriate
% color value.
out_red(mask) = color_uint8(1);
out_green(mask) = color_uint8(2);
out_blue(mask) = color_uint8(3);
% Form an RGB truecolor image by concatenating the channel matrices along
% the third dimension.
out = cat(3, out_red, out_green, out_blue);
⛄ 运行结果
⛄ 参考文献
[1] 康世英, 聂维. 基于MATLAB的道路裂缝识别研究[J]. 电脑知识与技术:学术版, 2020, 16(30):3.
[2] 王博. 基于Matlab图像处理的水泥路面裂缝检测研究[J]. 商洛学院学报, 2014, 28(4):5.
[3] 马文涛, 樊春玲. 基于计算机视觉路面裂缝的识别与测量[J]. 电子测量技术, 2020(019):043.
[4] 史英英. 基于图像处理的路面裂缝识别技术研究[J]. 四川水泥, 2022(11):3.